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 Create a CommunicationCreate a communication. Returns the created communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; HCkJsonObjectW jsonRequestBody; const wchar_t *url; HCkHttpResponseW resp; HCkJsonObjectW jsonResponse; int dataId; const wchar_t *dataCreated_at; const wchar_t *dataUpdated_at; int dataLead_id; int dataUser_id; const wchar_t *dataMethod; const wchar_t *dataType; const wchar_t *dataEmail_subject; const wchar_t *dataEmail_body; const wchar_t *dataEmail_client; const wchar_t *dataEmail_user; const wchar_t *dataCall_duration; const wchar_t *dataCall_phone; const wchar_t *dataCall_status; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); CkHttpW_putAuthToken(http,L"ACCESS_TOKEN"); CkHttpW_putAccept(http,L"application/json"); // The following JSON is sent in the request body: // { // "lead_id": "LEAD_ID", // "method": "phone", // "type": "outgoing", // "call_status": "calling" // } // Use this online tool to generate the code from sample JSON: // Generate Code to Create JSON jsonRequestBody = CkJsonObjectW_Create(); CkJsonObjectW_UpdateString(jsonRequestBody,L"lead_id",L"LEAD_ID"); CkJsonObjectW_UpdateString(jsonRequestBody,L"method",L"phone"); CkJsonObjectW_UpdateString(jsonRequestBody,L"type",L"outgoing"); CkJsonObjectW_UpdateString(jsonRequestBody,L"call_status",L"calling"); url = L"https://crm.activix.ca/api/v2/communications"; resp = CkHttpW_PText(http,L"POST",url,CkJsonObjectW_emit(jsonRequestBody),L"utf-8",L"application/json",FALSE,FALSE); if (CkHttpW_getLastMethodSuccess(http) != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonRequestBody); 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); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonRequestBody); CkJsonObjectW_Dispose(jsonResponse); return; } CkHttpResponseW_Dispose(resp); // Sample output... // (See the parsing code below..) // // Use the this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // { // "data": { // "id": 5411998, // "created_at": "2019-06-10T13:01:40+00:00", // "updated_at": "2019-06-10T13:01:40+00:00", // "lead_id": 7135833, // "user_id": 13705, // "method": "phone", // "type": "outgoing", // "email_subject": null, // "email_body": null, // "email_client": null, // "email_user": null, // "call_duration": null, // "call_phone": null, // "call_status": "calling" // } // } // dataId = CkJsonObjectW_IntOf(jsonResponse,L"data.id"); dataCreated_at = CkJsonObjectW_stringOf(jsonResponse,L"data.created_at"); dataUpdated_at = CkJsonObjectW_stringOf(jsonResponse,L"data.updated_at"); dataLead_id = CkJsonObjectW_IntOf(jsonResponse,L"data.lead_id"); dataUser_id = CkJsonObjectW_IntOf(jsonResponse,L"data.user_id"); dataMethod = CkJsonObjectW_stringOf(jsonResponse,L"data.method"); dataType = CkJsonObjectW_stringOf(jsonResponse,L"data.type"); dataEmail_subject = CkJsonObjectW_stringOf(jsonResponse,L"data.email_subject"); dataEmail_body = CkJsonObjectW_stringOf(jsonResponse,L"data.email_body"); dataEmail_client = CkJsonObjectW_stringOf(jsonResponse,L"data.email_client"); dataEmail_user = CkJsonObjectW_stringOf(jsonResponse,L"data.email_user"); dataCall_duration = CkJsonObjectW_stringOf(jsonResponse,L"data.call_duration"); dataCall_phone = CkJsonObjectW_stringOf(jsonResponse,L"data.call_phone"); dataCall_status = CkJsonObjectW_stringOf(jsonResponse,L"data.call_status"); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonRequestBody); CkJsonObjectW_Dispose(jsonResponse); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.