Sample code for 30+ languages & platforms
Node.js

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

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

    var req = new chilkat.HttpRequest();

    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 chilkat.Http();
    http.AuthToken = "ACCESS_TOKEN";

    var resp = new chilkat.HttpResponse();
    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 chilkat.JsonObject();
    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."
    //  }
    //  

}

chilkatExample();