Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *Name;
const wchar_t *Id;
const wchar_t *v_Email;
const wchar_t *Scurrency_symbol;
const wchar_t *Account_Type;
const wchar_t *SIC_Code;
const wchar_t *Ssharing_permission;
const wchar_t *Last_Activity_Time;
const wchar_t *Industry;
const wchar_t *Account_Site;
const wchar_t *Sstate;
BOOL Sprocess_flow;
int Exchange_Rate;
const wchar_t *Billing_Country;
const wchar_t *v_Currency;
const wchar_t *id;
BOOL Sapproved;
BOOL Delegate;
BOOL Approve;
BOOL Reject;
BOOL Resubmit;
const wchar_t *Billing_Street;
const wchar_t *Created_Time;
BOOL Seditable;
const wchar_t *Billing_Code;
const wchar_t *Shipping_City;
const wchar_t *Shipping_Country;
const wchar_t *Shipping_Code;
const wchar_t *Billing_City;
const wchar_t *Created_ByName;
const wchar_t *Created_ById;
const wchar_t *Created_ByEmail;
int Annual_Revenue;
const wchar_t *Shipping_Street;
const wchar_t *territory_updated_time;
const wchar_t *Ownership;
const wchar_t *Description;
const wchar_t *Rating;
const wchar_t *Shipping_State;
BOOL Sreview_processApprove;
BOOL Sreview_processReject;
BOOL Sreview_processResubmit;
const wchar_t *Website;
const wchar_t *Employees;
const wchar_t *Record_Image;
const wchar_t *Modified_ByName;
const wchar_t *Modified_ById;
const wchar_t *Modified_ByEmail;
const wchar_t *Sreview;
const wchar_t *Phone;
const wchar_t *Account_Name;
const wchar_t *Account_Number;
const wchar_t *Ticker_Symbol;
const wchar_t *Modified_Time;
BOOL Sorchestration;
const wchar_t *Parent_Account;
BOOL Sin_merge;
const wchar_t *Billing_State;
const wchar_t *Fax;
const wchar_t *Sapproval_state;
int j;
int count_j;
const wchar_t *Sassigned;
const wchar_t *Sassigned_time;
const wchar_t *Sassigned_by;
int Per_page;
int Count;
int Page;
BOOL More_records;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://domain.com/crm/v2.1/Accounts",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": [
// {
// "Owner": {
// "name": "patricia patricia",
// "id": "738964000000291009",
// "email": "patricia.ss@zylker.com"
// },
// "$currency_symbol": "Af",
// "Account_Type": null,
// "SIC_Code": null,
// "$sharing_permission": "full_access",
// "Last_Activity_Time": "2021-04-21T08:53:58+00:00",
// "Industry": null,
// "Account_Site": null,
// "$state": "save",
// "$process_flow": false,
// "Exchange_Rate": 1,
// "Billing_Country": null,
// "Currency": "AFN",
// "id": "738964000002058030",
// "$approved": true,
// "$approval": {
// "delegate": false,
// "approve": false,
// "reject": false,
// "resubmit": false
// },
// "Billing_Street": null,
// "Created_Time": "2021-04-21T08:53:58+00:00",
// "$editable": true,
// "Billing_Code": "1234",
// "Shipping_City": null,
// "Shipping_Country": null,
// "Shipping_Code": null,
// "Billing_City": null,
// "Created_By": {
// "name": "patricia patricia",
// "id": "738964000000291009",
// "email": "patricia.ss@zylker.com"
// },
// "Annual_Revenue": 1,
// "Shipping_Street": null,
// "territory_updated_time": null,
// "Ownership": null,
// "Description": null,
// "Rating": null,
// "Shipping_State": null,
// "$review_process": {
// "approve": false,
// "reject": false,
// "resubmit": false
// },
// "Website": "https://yaythisworked.com",
// "Employees": null,
// "Record_Image": null,
// "Modified_By": {
// "name": "patricia patricia",
// "id": "738964000000291009",
// "email": "patricia.ss@zylker.com"
// },
// "$review": null,
// "Phone": null,
// "Account_Name": "Zylker",
// "Account_Number": "0",
// "Ticker_Symbol": null,
// "Modified_Time": "2021-04-21T08:53:58+00:00",
// "Territories": [
// {
// "$assigned": "automatically",
// "$assigned_time": "2021-04-21T08:54:13+00:00",
// "id": "738964000001977355",
// "$assigned_by": null,
// "Name": "South Zone"
// }
// ],
// "$orchestration": false,
// "Parent_Account": null,
// "$in_merge": false,
// "Billing_State": "Colorado",
// "Tag": [
// ],
// "Fax": null,
// "$approval_state": "approved"
// }
// ],
// "info": {
// "per_page": 200,
// "count": 1,
// "page": 1,
// "more_records": false
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
Per_page = CkJsonObjectW_IntOf(jResp,L"info.per_page");
Count = CkJsonObjectW_IntOf(jResp,L"info.count");
Page = CkJsonObjectW_IntOf(jResp,L"info.page");
More_records = CkJsonObjectW_BoolOf(jResp,L"info.more_records");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"data");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
Name = CkJsonObjectW_stringOf(jResp,L"data[i].Owner.name");
Id = CkJsonObjectW_stringOf(jResp,L"data[i].Owner.id");
v_Email = CkJsonObjectW_stringOf(jResp,L"data[i].Owner.email");
Scurrency_symbol = CkJsonObjectW_stringOf(jResp,L"data[i].$currency_symbol");
Account_Type = CkJsonObjectW_stringOf(jResp,L"data[i].Account_Type");
SIC_Code = CkJsonObjectW_stringOf(jResp,L"data[i].SIC_Code");
Ssharing_permission = CkJsonObjectW_stringOf(jResp,L"data[i].$sharing_permission");
Last_Activity_Time = CkJsonObjectW_stringOf(jResp,L"data[i].Last_Activity_Time");
Industry = CkJsonObjectW_stringOf(jResp,L"data[i].Industry");
Account_Site = CkJsonObjectW_stringOf(jResp,L"data[i].Account_Site");
Sstate = CkJsonObjectW_stringOf(jResp,L"data[i].$state");
Sprocess_flow = CkJsonObjectW_BoolOf(jResp,L"data[i].$process_flow");
Exchange_Rate = CkJsonObjectW_IntOf(jResp,L"data[i].Exchange_Rate");
Billing_Country = CkJsonObjectW_stringOf(jResp,L"data[i].Billing_Country");
v_Currency = CkJsonObjectW_stringOf(jResp,L"data[i].Currency");
id = CkJsonObjectW_stringOf(jResp,L"data[i].id");
Sapproved = CkJsonObjectW_BoolOf(jResp,L"data[i].$approved");
Delegate = CkJsonObjectW_BoolOf(jResp,L"data[i].$approval.delegate");
Approve = CkJsonObjectW_BoolOf(jResp,L"data[i].$approval.approve");
Reject = CkJsonObjectW_BoolOf(jResp,L"data[i].$approval.reject");
Resubmit = CkJsonObjectW_BoolOf(jResp,L"data[i].$approval.resubmit");
Billing_Street = CkJsonObjectW_stringOf(jResp,L"data[i].Billing_Street");
Created_Time = CkJsonObjectW_stringOf(jResp,L"data[i].Created_Time");
Seditable = CkJsonObjectW_BoolOf(jResp,L"data[i].$editable");
Billing_Code = CkJsonObjectW_stringOf(jResp,L"data[i].Billing_Code");
Shipping_City = CkJsonObjectW_stringOf(jResp,L"data[i].Shipping_City");
Shipping_Country = CkJsonObjectW_stringOf(jResp,L"data[i].Shipping_Country");
Shipping_Code = CkJsonObjectW_stringOf(jResp,L"data[i].Shipping_Code");
Billing_City = CkJsonObjectW_stringOf(jResp,L"data[i].Billing_City");
Created_ByName = CkJsonObjectW_stringOf(jResp,L"data[i].Created_By.name");
Created_ById = CkJsonObjectW_stringOf(jResp,L"data[i].Created_By.id");
Created_ByEmail = CkJsonObjectW_stringOf(jResp,L"data[i].Created_By.email");
Annual_Revenue = CkJsonObjectW_IntOf(jResp,L"data[i].Annual_Revenue");
Shipping_Street = CkJsonObjectW_stringOf(jResp,L"data[i].Shipping_Street");
territory_updated_time = CkJsonObjectW_stringOf(jResp,L"data[i].territory_updated_time");
Ownership = CkJsonObjectW_stringOf(jResp,L"data[i].Ownership");
Description = CkJsonObjectW_stringOf(jResp,L"data[i].Description");
Rating = CkJsonObjectW_stringOf(jResp,L"data[i].Rating");
Shipping_State = CkJsonObjectW_stringOf(jResp,L"data[i].Shipping_State");
Sreview_processApprove = CkJsonObjectW_BoolOf(jResp,L"data[i].$review_process.approve");
Sreview_processReject = CkJsonObjectW_BoolOf(jResp,L"data[i].$review_process.reject");
Sreview_processResubmit = CkJsonObjectW_BoolOf(jResp,L"data[i].$review_process.resubmit");
Website = CkJsonObjectW_stringOf(jResp,L"data[i].Website");
Employees = CkJsonObjectW_stringOf(jResp,L"data[i].Employees");
Record_Image = CkJsonObjectW_stringOf(jResp,L"data[i].Record_Image");
Modified_ByName = CkJsonObjectW_stringOf(jResp,L"data[i].Modified_By.name");
Modified_ById = CkJsonObjectW_stringOf(jResp,L"data[i].Modified_By.id");
Modified_ByEmail = CkJsonObjectW_stringOf(jResp,L"data[i].Modified_By.email");
Sreview = CkJsonObjectW_stringOf(jResp,L"data[i].$review");
Phone = CkJsonObjectW_stringOf(jResp,L"data[i].Phone");
Account_Name = CkJsonObjectW_stringOf(jResp,L"data[i].Account_Name");
Account_Number = CkJsonObjectW_stringOf(jResp,L"data[i].Account_Number");
Ticker_Symbol = CkJsonObjectW_stringOf(jResp,L"data[i].Ticker_Symbol");
Modified_Time = CkJsonObjectW_stringOf(jResp,L"data[i].Modified_Time");
Sorchestration = CkJsonObjectW_BoolOf(jResp,L"data[i].$orchestration");
Parent_Account = CkJsonObjectW_stringOf(jResp,L"data[i].Parent_Account");
Sin_merge = CkJsonObjectW_BoolOf(jResp,L"data[i].$in_merge");
Billing_State = CkJsonObjectW_stringOf(jResp,L"data[i].Billing_State");
Fax = CkJsonObjectW_stringOf(jResp,L"data[i].Fax");
Sapproval_state = CkJsonObjectW_stringOf(jResp,L"data[i].$approval_state");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"data[i].Territories");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
Sassigned = CkJsonObjectW_stringOf(jResp,L"data[i].Territories[j].$assigned");
Sassigned_time = CkJsonObjectW_stringOf(jResp,L"data[i].Territories[j].$assigned_time");
id = CkJsonObjectW_stringOf(jResp,L"data[i].Territories[j].id");
Sassigned_by = CkJsonObjectW_stringOf(jResp,L"data[i].Territories[j].$assigned_by");
Name = CkJsonObjectW_stringOf(jResp,L"data[i].Territories[j].Name");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"data[i].Tag");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
j = j + 1;
}
i = i + 1;
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2.1/Accounts
Postman Collection Item JSON
{
"name": "Accounts",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts"
]
},
"description": "To get the list of available records in the Accounts module."
},
"response": [
{
"name": "P8: territory_id",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts?territory_id=738964000001977355",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts"
],
"query": [
{
"key": "territory_id",
"value": "738964000001977355"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 05 May 2021 06:44:50 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-05T07:39:40+00:00"
},
{
"key": "clientVersion",
"value": "4009533"
},
{
"key": "clientsubVersion",
"value": "cfa914635a0a376a1322139140e8bf37"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "vary",
"value": "accept-encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\n \"Owner\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$currency_symbol\": \"Af\",\n \"Account_Type\": null,\n \"SIC_Code\": null,\n \"$sharing_permission\": \"full_access\",\n \"Last_Activity_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Industry\": null,\n \"Account_Site\": null,\n \"$state\": \"save\",\n \"$process_flow\": false,\n \"Exchange_Rate\": 1,\n \"Billing_Country\": null,\n \"Currency\": \"AFN\",\n \"id\": \"738964000002058030\",\n \"$approved\": true,\n \"$approval\": {\n \"delegate\": false,\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Billing_Street\": null,\n \"Created_Time\": \"2021-04-21T08:53:58+00:00\",\n \"$editable\": true,\n \"Billing_Code\": \"1234\",\n \"Shipping_City\": null,\n \"Shipping_Country\": null,\n \"Shipping_Code\": null,\n \"Billing_City\": null,\n \"Created_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Annual_Revenue\": 1,\n \"Shipping_Street\": null,\n \"territory_updated_time\": null,\n \"Ownership\": null,\n \"Description\": null,\n \"Rating\": null,\n \"Shipping_State\": null,\n \"$review_process\": {\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Website\": \"https://yaythisworked.com\",\n \"Employees\": null,\n \"Record_Image\": null,\n \"Modified_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$review\": null,\n \"Phone\": null,\n \"Account_Name\": \"Zylker\",\n \"Account_Number\": \"0\",\n \"Ticker_Symbol\": null,\n \"Modified_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Territories\": [\n {\n \"$assigned\": \"automatically\",\n \"$assigned_time\": \"2021-04-21T08:54:13+00:00\",\n \"id\": \"738964000001977355\",\n \"$assigned_by\": null,\n \"Name\": \"South Zone\"\n }\n ],\n \"$orchestration\": false,\n \"Parent_Account\": null,\n \"$in_merge\": false,\n \"Billing_State\": \"Colorado\",\n \"Tag\": [],\n \"Fax\": null,\n \"$approval_state\": \"approved\"\n }\n ],\n \"info\": {\n \"per_page\": 200,\n \"count\": 1,\n \"page\": 1,\n \"more_records\": false\n }\n}"
},
{
"name": "P9: include_child",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts?territory_id=738964000001977355&include_child=true",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts"
],
"query": [
{
"key": "territory_id",
"value": "738964000001977355"
},
{
"key": "include_child",
"value": "true"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 05 May 2021 06:45:34 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-05T07:39:40+00:00"
},
{
"key": "clientVersion",
"value": "4009533"
},
{
"key": "clientsubVersion",
"value": "cfa914635a0a376a1322139140e8bf37"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "vary",
"value": "accept-encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\n \"Owner\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$currency_symbol\": \"Af\",\n \"Account_Type\": null,\n \"SIC_Code\": null,\n \"$sharing_permission\": \"full_access\",\n \"Last_Activity_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Industry\": null,\n \"Account_Site\": null,\n \"$state\": \"save\",\n \"$process_flow\": false,\n \"Exchange_Rate\": 1,\n \"Billing_Country\": null,\n \"Currency\": \"AFN\",\n \"id\": \"738964000002058030\",\n \"$approved\": true,\n \"$approval\": {\n \"delegate\": false,\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Billing_Street\": null,\n \"Created_Time\": \"2021-04-21T08:53:58+00:00\",\n \"$editable\": true,\n \"Billing_Code\": \"1234\",\n \"Shipping_City\": null,\n \"Shipping_Country\": null,\n \"Shipping_Code\": null,\n \"Billing_City\": null,\n \"Created_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Annual_Revenue\": 1,\n \"Shipping_Street\": null,\n \"territory_updated_time\": null,\n \"Ownership\": null,\n \"Description\": null,\n \"Rating\": null,\n \"Shipping_State\": null,\n \"$review_process\": {\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Website\": \"https://yaythisworked.com\",\n \"Employees\": null,\n \"Record_Image\": null,\n \"Modified_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$review\": null,\n \"Phone\": null,\n \"Account_Name\": \"Zylker\",\n \"Account_Number\": \"0\",\n \"Ticker_Symbol\": null,\n \"Modified_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Territories\": [\n {\n \"$assigned\": \"automatically\",\n \"$assigned_time\": \"2021-04-21T08:54:13+00:00\",\n \"id\": \"738964000001977355\",\n \"$assigned_by\": null,\n \"Name\": \"South Zone\"\n }\n ],\n \"$orchestration\": false,\n \"Parent_Account\": null,\n \"$in_merge\": false,\n \"Billing_State\": \"Colorado\",\n \"Tag\": [],\n \"Fax\": null,\n \"$approval_state\": \"approved\"\n }\n ],\n \"info\": {\n \"per_page\": 200,\n \"count\": 1,\n \"page\": 1,\n \"more_records\": false\n }\n}"
}
]
}