Sample code for 30+ languages & platforms
Perl

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

my $req = Chilkat2::HttpRequest->new;

$req->HttpVerb('POST');
$req->Path('/api/v2/communications/COMMUNICATION_ID/recording');
$req->ContentType('multipart/form-data');

$req->AddHeader('Accept', 'application/json');

my $pathToFileOnDisk = 'qa_data/CantinaBand3.wav';
my $success = $req->AddFileForUpload('recording', $pathToFileOnDisk);
if (!$success) {
    print $req->LastErrorText, "\n";
    exit;
}

my $http = Chilkat2::Http->new;
$http->AuthToken('ACCESS_TOKEN');

my $resp = Chilkat2::HttpResponse->new;
$success = $http->HttpSReq('crm.activix.ca', 443, 1, $req, $resp);
if (!$success) {
    print $http->LastErrorText, "\n";
    exit;
}

print 'Response Status Code: ', $resp->StatusCode, "\n";

my $jsonResponse = Chilkat2::JsonObject->new;
$jsonResponse->Load($resp->BodyStr);
$jsonResponse->EmitCompact(0);
print $jsonResponse->Emit(), "\n";

if ($resp->StatusCode >= 300) {
    print "Failed.\n";
    exit;
}

# Sample output...

# {
#   "message": "Recording uploaded successfully."
# }
#