Sample code for 30+ languages & platforms
Perl

Send a Bodyless REST Request into a StringBuilder

See more REST Examples

Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.

Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $rest = Chilkat2::Rest->new;
my $bTls = 1;
my $bAutoReconnect = 1;
my $success = $rest->Connect('example.com', 443, $bTls, $bAutoReconnect);
if (!$success) {
    print $rest->LastErrorText, "\n";
    exit;
}

# FullRequestNoBodySb sends a request with no body and stores the text response body in a
# StringBuilder.
my $sbResponse = Chilkat2::StringBuilder->new;
$success = $rest->FullRequestNoBodySb('GET', '/api/items/123', $sbResponse);
if (!$success) {
    print $rest->LastErrorText, "\n";
    exit;
}

my $responseText = $sbResponse->GetAsString();
if (!$sbResponse->LastMethodSuccess) {
    print $sbResponse->LastErrorText, "\n";
    exit;
}

print $responseText, "\n";