Perl
Chilkat2 Perl
Clear All Multipart Parts
See more REST Examples
Demonstrates Rest.ClearAllParts, which removes all multipart subparts from the request under construction.
Background. Clearing the parts is useful when reusing the same Rest object to build a different multipart request.
Chilkat Perl Downloads
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;
}
# Build a part.
$rest->PartSelector('1');
$success = $rest->SetMultipartBodyString('value1');
if (!$success) {
print $rest->LastErrorText, "\n";
exit;
}
# Remove all multipart subparts from the request under construction, for example before reusing the
# same Rest object for a different multipart request.
$rest->ClearAllParts();
print "All multipart parts cleared.\n";