Back to Collection Items
var
http: HCkHttp;
success: Boolean;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
country: PWideChar;
photo_id: PWideChar;
city: PWideChar;
description: PWideChar;
mc_status: Boolean;
gapps_enabled: Boolean;
domain_name: PWideChar;
translation_enabled: Boolean;
street: PWideChar;
alias: PWideChar;
v_currency: PWideChar;
id: PWideChar;
state: PWideChar;
fax: PWideChar;
employee_count: PWideChar;
zip: PWideChar;
website: PWideChar;
currency_symbol: PWideChar;
mobile: PWideChar;
currency_locale: PWideChar;
primary_zuid: PWideChar;
zia_portal_id: PWideChar;
time_zone: PWideChar;
zgid: PWideChar;
country_code: PWideChar;
Paid_expiry: PWideChar;
Users_license_purchased: Integer;
Trial_type: PWideChar;
Trial_expiry: PWideChar;
Paid: Boolean;
Paid_type: PWideChar;
phone: PWideChar;
company_name: PWideChar;
privacy_settings: Boolean;
primary_email: PWideChar;
iso_code: PWideChar;
i: Integer;
count_i: Integer;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
CkHttp_SetRequestHeader(http,'Authorization','{{authorization-token}}');
sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://domain.com/crm/v2/org',sbResponseBody);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttp__lastHeader(http));
Memo1.Lines.Add('Failed.');
Exit;
end;
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "org": [
// {
// "country": null,
// "photo_id": null,
// "city": null,
// "description": null,
// "mc_status": true,
// "gapps_enabled": false,
// "domain_name": "org60036018",
// "translation_enabled": true,
// "street": null,
// "alias": null,
// "currency": "Indian Rupee",
// "id": "738964000000300043",
// "state": null,
// "fax": null,
// "employee_count": null,
// "zip": null,
// "website": null,
// "currency_symbol": "",
// "mobile": null,
// "currency_locale": "en_IN",
// "primary_zuid": "60034346",
// "zia_portal_id": null,
// "time_zone": "Asia/Kolkata",
// "zgid": "60036018",
// "country_code": "IN",
// "license_details": {
// "paid_expiry": "2021-10-20T00:00:00+00:00",
// "users_license_purchased": 25,
// "trial_type": null,
// "trial_expiry": null,
// "paid": true,
// "paid_type": "enterprise"
// },
// "phone": "312",
// "company_name": "Zylker",
// "privacy_settings": true,
// "primary_email": "patricia@zylker.com",
// "iso_code": "INR"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'org');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
country := CkJsonObject__stringOf(jResp,'org[i].country');
photo_id := CkJsonObject__stringOf(jResp,'org[i].photo_id');
city := CkJsonObject__stringOf(jResp,'org[i].city');
description := CkJsonObject__stringOf(jResp,'org[i].description');
mc_status := CkJsonObject_BoolOf(jResp,'org[i].mc_status');
gapps_enabled := CkJsonObject_BoolOf(jResp,'org[i].gapps_enabled');
domain_name := CkJsonObject__stringOf(jResp,'org[i].domain_name');
translation_enabled := CkJsonObject_BoolOf(jResp,'org[i].translation_enabled');
street := CkJsonObject__stringOf(jResp,'org[i].street');
alias := CkJsonObject__stringOf(jResp,'org[i].alias');
v_currency := CkJsonObject__stringOf(jResp,'org[i].currency');
id := CkJsonObject__stringOf(jResp,'org[i].id');
state := CkJsonObject__stringOf(jResp,'org[i].state');
fax := CkJsonObject__stringOf(jResp,'org[i].fax');
employee_count := CkJsonObject__stringOf(jResp,'org[i].employee_count');
zip := CkJsonObject__stringOf(jResp,'org[i].zip');
website := CkJsonObject__stringOf(jResp,'org[i].website');
currency_symbol := CkJsonObject__stringOf(jResp,'org[i].currency_symbol');
mobile := CkJsonObject__stringOf(jResp,'org[i].mobile');
currency_locale := CkJsonObject__stringOf(jResp,'org[i].currency_locale');
primary_zuid := CkJsonObject__stringOf(jResp,'org[i].primary_zuid');
zia_portal_id := CkJsonObject__stringOf(jResp,'org[i].zia_portal_id');
time_zone := CkJsonObject__stringOf(jResp,'org[i].time_zone');
zgid := CkJsonObject__stringOf(jResp,'org[i].zgid');
country_code := CkJsonObject__stringOf(jResp,'org[i].country_code');
Paid_expiry := CkJsonObject__stringOf(jResp,'org[i].license_details.paid_expiry');
Users_license_purchased := CkJsonObject_IntOf(jResp,'org[i].license_details.users_license_purchased');
Trial_type := CkJsonObject__stringOf(jResp,'org[i].license_details.trial_type');
Trial_expiry := CkJsonObject__stringOf(jResp,'org[i].license_details.trial_expiry');
Paid := CkJsonObject_BoolOf(jResp,'org[i].license_details.paid');
Paid_type := CkJsonObject__stringOf(jResp,'org[i].license_details.paid_type');
phone := CkJsonObject__stringOf(jResp,'org[i].phone');
company_name := CkJsonObject__stringOf(jResp,'org[i].company_name');
privacy_settings := CkJsonObject_BoolOf(jResp,'org[i].privacy_settings');
primary_email := CkJsonObject__stringOf(jResp,'org[i].primary_email');
iso_code := CkJsonObject__stringOf(jResp,'org[i].iso_code');
i := i + 1;
end;
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
-H "Authorization: {{authorization-token}}"
https://domain.com/crm/v2/org
Postman Collection Item JSON
{
"name": "Organization Details",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"url": {
"raw": "{{api-domain}}/crm/v2/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"org"
]
},
"description": "To get the organization data."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"url": {
"raw": "{{api-domain}}/crm/v2/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"org"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 10:49:49 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "796"
},
{
"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-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-11T11:08:26+00:00"
},
{
"key": "clientVersion",
"value": "4023320"
},
{
"key": "clientsubVersion",
"value": "4d8b6ee4f7d1d284c930a4e807480c5c"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"org\": [\n {\n \"country\": null,\n \"photo_id\": null,\n \"city\": null,\n \"description\": null,\n \"mc_status\": true,\n \"gapps_enabled\": false,\n \"domain_name\": \"org60036018\",\n \"translation_enabled\": true,\n \"street\": null,\n \"alias\": null,\n \"currency\": \"Indian Rupee\",\n \"id\": \"738964000000300043\",\n \"state\": null,\n \"fax\": null,\n \"employee_count\": null,\n \"zip\": null,\n \"website\": null,\n \"currency_symbol\": \"₹\",\n \"mobile\": null,\n \"currency_locale\": \"en_IN\",\n \"primary_zuid\": \"60034346\",\n \"zia_portal_id\": null,\n \"time_zone\": \"Asia/Kolkata\",\n \"zgid\": \"60036018\",\n \"country_code\": \"IN\",\n \"license_details\": {\n \"paid_expiry\": \"2021-10-20T00:00:00+00:00\",\n \"users_license_purchased\": 25,\n \"trial_type\": null,\n \"trial_expiry\": null,\n \"paid\": true,\n \"paid_type\": \"enterprise\"\n },\n \"phone\": \"312\",\n \"company_name\": \"Zylker\",\n \"privacy_settings\": true,\n \"primary_email\": \"patricia@zylker.com\",\n \"iso_code\": \"INR\"\n }\n ]\n}"
},
{
"name": "INVALID_REQUEST_METHOD",
"originalRequest": {
"method": "COPY",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"url": {
"raw": "{{api-domain}}/crm/v2/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"org"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 10:50:28 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "124"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Frame-Options",
"value": "deny"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_REQUEST_METHOD\",\n \"details\": {},\n \"message\": \"The http request method type is not a valid one\",\n \"status\": \"error\"\n}"
},
{
"name": "AUTHENTICATION_FAILURE",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"url": {
"raw": "{{api-domain}}/crm/v2/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"org"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 10:52:27 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "98"
},
{
"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-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"AUTHENTICATION_FAILURE\",\n \"details\": {},\n \"message\": \"Authentication failed\",\n \"status\": \"error\"\n}"
},
{
"name": "OAUTH_SCOPE_MISMATCH",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"url": {
"raw": "{{api-domain}}/crm/v2/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"org"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Thu, 13 May 2021 06:31:49 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "113"
},
{
"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-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"OAUTH_SCOPE_MISMATCH\",\n \"details\": {},\n \"message\": \"invalid oauth scope to access this URL\",\n \"status\": \"error\"\n}"
}
]
}