Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Activix CRM Upload a RecordingUpload a recording for an existing communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
#include <C_CkHttpRequestW.h> #include <C_CkHttpW.h> #include <C_CkHttpResponseW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpRequestW req; const wchar_t *pathToFileOnDisk; BOOL success; HCkHttpW http; HCkHttpResponseW resp; HCkJsonObjectW jsonResponse; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. req = CkHttpRequestW_Create(); CkHttpRequestW_putHttpVerb(req,L"POST"); CkHttpRequestW_putPath(req,L"/api/v2/communications/COMMUNICATION_ID/recording"); CkHttpRequestW_putContentType(req,L"multipart/form-data"); CkHttpRequestW_AddHeader(req,L"Accept",L"application/json"); pathToFileOnDisk = L"qa_data/CantinaBand3.wav"; success = CkHttpRequestW_AddFileForUpload(req,L"recording",pathToFileOnDisk); if (success != TRUE) { wprintf(L"%s\n",CkHttpRequestW_lastErrorText(req)); CkHttpRequestW_Dispose(req); return; } http = CkHttpW_Create(); CkHttpW_putAuthToken(http,L"ACCESS_TOKEN"); resp = CkHttpW_SynchronousRequest(http,L"crm.activix.ca",443,TRUE,req); if (CkHttpW_getLastMethodSuccess(http) != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpRequestW_Dispose(req); CkHttpW_Dispose(http); return; } wprintf(L"Response Status Code: %d\n",CkHttpResponseW_getStatusCode(resp)); jsonResponse = CkJsonObjectW_Create(); CkJsonObjectW_Load(jsonResponse,CkHttpResponseW_bodyStr(resp)); CkJsonObjectW_putEmitCompact(jsonResponse,FALSE); wprintf(L"%s\n",CkJsonObjectW_emit(jsonResponse)); if (CkHttpResponseW_getStatusCode(resp) >= 300) { wprintf(L"Failed.\n"); CkHttpResponseW_Dispose(resp); CkHttpRequestW_Dispose(req); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonResponse); return; } CkHttpResponseW_Dispose(resp); // Sample output... // { // "message": "Recording uploaded successfully." // } // CkHttpRequestW_Dispose(req); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonResponse); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.