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 PhoneCreate a phone. Returns the created phone. For more information, see https://docs.crm.activix.ca/api/resources/phone
#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; const wchar_t *dataExtension; const wchar_t *dataNumber; const wchar_t *dataType; BOOL dataValid; const wchar_t *dataValidated; BOOL dataMobile; // 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": 7135833, // "number": "+15141234455", // "type": "home" // } // Use this online tool to generate the code from sample JSON: // Generate Code to Create JSON jsonRequestBody = CkJsonObjectW_Create(); CkJsonObjectW_UpdateInt(jsonRequestBody,L"lead_id",7135833); CkJsonObjectW_UpdateString(jsonRequestBody,L"number",L"+15141234455"); CkJsonObjectW_UpdateString(jsonRequestBody,L"type",L"home"); url = L"https://crm.activix.ca/api/v2/lead-phones"; 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": 34566, // "created_at": "2018-04-09T18:05:00+00:00", // "updated_at": "2018-04-09T18:05:00+00:00", // "lead_id": 3466512, // "number": "+15141234455", // ... // } // } 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"); dataExtension = CkJsonObjectW_stringOf(jsonResponse,L"data.extension"); dataNumber = CkJsonObjectW_stringOf(jsonResponse,L"data.number"); dataType = CkJsonObjectW_stringOf(jsonResponse,L"data.type"); dataValid = CkJsonObjectW_BoolOf(jsonResponse,L"data.valid"); dataValidated = CkJsonObjectW_stringOf(jsonResponse,L"data.validated"); dataMobile = CkJsonObjectW_BoolOf(jsonResponse,L"data.mobile"); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonRequestBody); CkJsonObjectW_Dispose(jsonResponse); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.