Showing results for 
Search instead for 
Did you mean: 

Tech Tip: Using the RESTful Control API with Perl - deletepool

The following code uses Stingray's RESTful API to delete a pool.  The code is written in Perl.  This program deletes the "pltest" pool created by the example.  To delete a resource you do a HTTP DELETE on the URI for the resource.  If the delete is successful a 204 HTTP status code will be returned.



use REST::Client;

use MIME::Base64;

use JSON;

# Since Stingray is using a self-signed certificate we don't need to verify it


my $poolName = 'pltest';

my $url = "/api/tm/1.0/config/active/pools/$poolName";

# Set up the connection

my $client = REST::Client->new();


$client->addHeader("Authorization", "Basic " . encode_base64("admin:admin"));

#First see if the pool already exists


if ($client->responseCode == 204) {

    print "Pool $poolName deleted";

} elsif ($client->responseCode == 404) {

    print "Pool $poolName not found";

} else {

    print "Error deleting pool $poolName. Status: " . $client->responseCode . " URL: $url";



Running the example


This code was tested with Perl 5.14.2 and version 249 of the REST::Client module.


Run the Perl script as follows:



Pool pltest deleted


Read More



Version history
Revision #:
2 of 2
Last update:
‎01-06-2021 04:09:PM
Updated by:
Labels (1)