React Native
React Native
Activix CRM Upload a Recording
See more Activix CRM Examples
Upload a recording for an existing communication.Chilkat React Native Downloads
import { Http, HttpRequest, HttpResponse, JsonObject } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const req = new HttpRequest();
req.httpVerb = 'POST';
req.path = '/api/v2/communications/COMMUNICATION_ID/recording';
req.contentType = 'multipart/form-data';
req.addHeader('Accept', 'application/json');
const pathToFileOnDisk = 'qa_data/CantinaBand3.wav';
try {
req.addFileForUpload('recording', pathToFileOnDisk);
} catch {
console.log(req.lastErrorText);
return;
}
const http = new Http();
http.authToken = 'ACCESS_TOKEN';
const resp = new HttpResponse();
try {
await http.httpSReqAsync('crm.activix.ca', 443, true, req, resp);
} catch {
console.log(http.lastErrorText);
return;
}
console.log(`Response Status Code: ${resp.statusCode}`);
const jsonResponse = new 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."
// }
//
}