(Unicode C++) Activix CRM Upload a Recording
Upload a recording for an existing communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
#include <CkHttpRequestW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpRequestW req;
req.put_HttpVerb(L"POST");
req.put_Path(L"/api/v2/communications/COMMUNICATION_ID/recording");
req.put_ContentType(L"multipart/form-data");
req.AddHeader(L"Accept",L"application/json");
const wchar_t *pathToFileOnDisk = L"qa_data/CantinaBand3.wav";
bool success = req.AddFileForUpload(L"recording",pathToFileOnDisk);
if (success != true) {
wprintf(L"%s\n",req.lastErrorText());
return;
}
CkHttpW http;
http.put_AuthToken(L"ACCESS_TOKEN");
CkHttpResponseW *resp = http.SynchronousRequest(L"crm.activix.ca",443,true,req);
if (http.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"Response Status Code: %d\n",resp->get_StatusCode());
CkJsonObjectW jsonResponse;
jsonResponse.Load(resp->bodyStr());
jsonResponse.put_EmitCompact(false);
wprintf(L"%s\n",jsonResponse.emit());
if (resp->get_StatusCode() >= 300) {
wprintf(L"Failed.\n");
delete resp;
return;
}
delete resp;
// Sample output...
// {
// "message": "Recording uploaded successfully."
// }
//
}
|