Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "data": [
// {
// "Owner": {
// "id": "{{user-id}}"
// },
// "Parent_Account": {
// "id": "{{parent-account-id}}"
// },
// "Ownership": "Private",
// "Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
// "Account_Type": "Competitor",
// "Rating": "Active",
// "SIC_Code": 12792,
// "Shipping_State": "Shipping_State",
// "Website": "crm.zoho.com",
// "Employees": 12792,
// "Industry": "Data/Telecom OEM",
// "Account_Site": "Account_Site",
// "Phone": "988844559",
// "Billing_Country": "Billing_Country",
// "Account_Name": "Account_Name",
// "Account_Number": "1245681",
// "Ticker_Symbol": "Ticker_Symbol",
// "Billing_Street": "Billing_Street",
// "Billing_Code": "Billing_Code",
// "Shipping_City": "Shipping_City",
// "Shipping_Country": "Shipping_Country",
// "Shipping_Code": "Shipping_Code",
// "Billing_City": "Billing_City",
// "Billing_State": "Billing_State",
// "Fax": "Fax",
// "Annual_Revenue": 127.67,
// "Shipping_Street": "Shipping_Street"
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"data[0].Owner.id",L"{{user-id}}");
CkJsonObjectW_UpdateString(json,L"data[0].Parent_Account.id",L"{{parent-account-id}}");
CkJsonObjectW_UpdateString(json,L"data[0].Ownership",L"Private");
CkJsonObjectW_UpdateString(json,L"data[0].Description",L"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.");
CkJsonObjectW_UpdateString(json,L"data[0].Account_Type",L"Competitor");
CkJsonObjectW_UpdateString(json,L"data[0].Rating",L"Active");
CkJsonObjectW_UpdateInt(json,L"data[0].SIC_Code",12792);
CkJsonObjectW_UpdateString(json,L"data[0].Shipping_State",L"Shipping_State");
CkJsonObjectW_UpdateString(json,L"data[0].Website",L"crm.zoho.com");
CkJsonObjectW_UpdateInt(json,L"data[0].Employees",12792);
CkJsonObjectW_UpdateString(json,L"data[0].Industry",L"Data/Telecom OEM");
CkJsonObjectW_UpdateString(json,L"data[0].Account_Site",L"Account_Site");
CkJsonObjectW_UpdateString(json,L"data[0].Phone",L"988844559");
CkJsonObjectW_UpdateString(json,L"data[0].Billing_Country",L"Billing_Country");
CkJsonObjectW_UpdateString(json,L"data[0].Account_Name",L"Account_Name");
CkJsonObjectW_UpdateString(json,L"data[0].Account_Number",L"1245681");
CkJsonObjectW_UpdateString(json,L"data[0].Ticker_Symbol",L"Ticker_Symbol");
CkJsonObjectW_UpdateString(json,L"data[0].Billing_Street",L"Billing_Street");
CkJsonObjectW_UpdateString(json,L"data[0].Billing_Code",L"Billing_Code");
CkJsonObjectW_UpdateString(json,L"data[0].Shipping_City",L"Shipping_City");
CkJsonObjectW_UpdateString(json,L"data[0].Shipping_Country",L"Shipping_Country");
CkJsonObjectW_UpdateString(json,L"data[0].Shipping_Code",L"Shipping_Code");
CkJsonObjectW_UpdateString(json,L"data[0].Billing_City",L"Billing_City");
CkJsonObjectW_UpdateString(json,L"data[0].Billing_State",L"Billing_State");
CkJsonObjectW_UpdateString(json,L"data[0].Fax",L"Fax");
CkJsonObjectW_UpdateNumber(json,L"data[0].Annual_Revenue",L"127.67");
CkJsonObjectW_UpdateString(json,L"data[0].Shipping_Street",L"Shipping_Street");
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization-token}}");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
resp = CkHttpW_PostJson3(http,L"https://domain.com/crm/v2.1/Accounts/upsert",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Authorization: {{authorization-token}}"
-H "Content-Type: application/json"
-d '{
"data": [
{
"Owner": {
"id": "{{user-id}}"
},
"Parent_Account": {
"id": "{{parent-account-id}}"
},
"Ownership": "Private",
"Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
"Account_Type": "Competitor",
"Rating": "Active",
"SIC_Code": 12792,
"Shipping_State": "Shipping_State",
"Website": "crm.zoho.com",
"Employees": 12792,
"Industry": "Data/Telecom OEM",
"Account_Site": "Account_Site",
"Phone": "988844559",
"Billing_Country": "Billing_Country",
"Account_Name": "Account_Name",
"Account_Number": "1245681",
"Ticker_Symbol": "Ticker_Symbol",
"Billing_Street": "Billing_Street",
"Billing_Code": "Billing_Code",
"Shipping_City": "Shipping_City",
"Shipping_Country": "Shipping_Country",
"Shipping_Code": "Shipping_Code",
"Billing_City": "Billing_City",
"Billing_State": "Billing_State",
"Fax": "Fax",
"Annual_Revenue": 127.67,
"Shipping_Street": "Shipping_Street"
}
]
}'
https://domain.com/crm/v2.1/Accounts/upsert
Postman Collection Item JSON
{
"name": "Accounts",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"data\": [\n\t\t{\n\t\t\t\"Owner\": {\n\t\t\t\t\"id\": \"{{user-id}}\"\n\t\t\t},\n\t\t\t\"Parent_Account\": {\n\t\t\t\t\"id\": \"{{parent-account-id}}\"\n\t\t\t},\n\t\t\t\"Ownership\": \"Private\",\n\t\t\t\"Description\": \"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.\",\n\t\t\t\"Account_Type\": \"Competitor\",\n\t\t\t\"Rating\": \"Active\",\n\t\t\t\"SIC_Code\": 12792,\n\t\t\t\"Shipping_State\": \"Shipping_State\",\n\t\t\t\"Website\": \"crm.zoho.com\",\n\t\t\t\"Employees\": 12792,\n\t\t\t\"Industry\": \"Data/Telecom OEM\",\n\t\t\t\"Account_Site\": \"Account_Site\",\n\t\t\t\"Phone\": \"988844559\",\n\t\t\t\"Billing_Country\": \"Billing_Country\",\n\t\t\t\"Account_Name\": \"Account_Name\",\n\t\t\t\"Account_Number\": \"1245681\",\n\t\t\t\"Ticker_Symbol\": \"Ticker_Symbol\",\n\t\t\t\"Billing_Street\": \"Billing_Street\",\n\t\t\t\"Billing_Code\": \"Billing_Code\",\n\t\t\t\"Shipping_City\": \"Shipping_City\",\n\t\t\t\"Shipping_Country\": \"Shipping_Country\",\n\t\t\t\"Shipping_Code\": \"Shipping_Code\",\n\t\t\t\"Billing_City\": \"Billing_City\",\n\t\t\t\"Billing_State\": \"Billing_State\",\n\t\t\t\"Fax\": \"Fax\",\n\t\t\t\"Annual_Revenue\": 127.67,\n\t\t\t\"Shipping_Street\": \"Shipping_Street\"\n\t\t}\n\t]\n}"
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts/upsert",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts",
"upsert"
]
},
"description": "To upsert Account records."
},
"response": [
]
}