Sample code for 30+ languages & platforms
JavaScript

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var req = new CkHttpRequest();

req.HttpVerb = "POST";
req.Path = "/api/v2/communications/COMMUNICATION_ID/recording";
req.ContentType = "multipart/form-data";

req.AddHeader("Accept","application/json");

var pathToFileOnDisk = "qa_data/CantinaBand3.wav";
success = req.AddFileForUpload("recording",pathToFileOnDisk);
if (success == false) {
    console.log(req.LastErrorText);
    return;
}

var http = new CkHttp();
http.AuthToken = "ACCESS_TOKEN";

var resp = new CkHttpResponse();
success = http.HttpSReq("crm.activix.ca",443,true,req,resp);
if (success == false) {
    console.log(http.LastErrorText);
    return;
}

console.log("Response Status Code: " + resp.StatusCode);

var jsonResponse = new CkJsonObject();
jsonResponse.Load(resp.BodyStr);
jsonResponse.EmitCompact = false;
console.log(jsonResponse.Emit());

if (resp.StatusCode >= 300) {
    console.log("Failed.");
    return;
}

// Sample output...

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