Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
CkHttp::ckSetRequestHeader(http,"Authorization","{{authorization-token}}")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://domain.com/crm/v2.1/org",sbResponseBody)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttp::ckLastStatus(http)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttp::ckLastHeader(http)
Debug "Failed."
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "org": [
; {
; "country": null,
; "hierarchy_preferences": {
; "type": "Role_Hierarchy"
; },
; "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": false,
; "primary_email": "patricia@zohocorp.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
country.s
v_Type.s
photo_id.s
city.s
description.s
mc_status.i
gapps_enabled.i
domain_name.s
translation_enabled.i
street.s
alias.s
v_currency.s
id.s
state.s
fax.s
employee_count.s
zip.s
website.s
currency_symbol.s
mobile.s
currency_locale.s
primary_zuid.s
zia_portal_id.s
time_zone.s
zgid.s
country_code.s
Paid_expiry.s
Users_license_purchased.i
Trial_type.s
Trial_expiry.s
Paid.i
Paid_type.s
phone.s
company_name.s
privacy_settings.i
primary_email.s
iso_code.s
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"org")
While i < count_i
CkJsonObject::setCkI(jResp, i)
country = CkJsonObject::ckStringOf(jResp,"org[i].country")
v_Type = CkJsonObject::ckStringOf(jResp,"org[i].hierarchy_preferences.type")
photo_id = CkJsonObject::ckStringOf(jResp,"org[i].photo_id")
city = CkJsonObject::ckStringOf(jResp,"org[i].city")
description = CkJsonObject::ckStringOf(jResp,"org[i].description")
mc_status = CkJsonObject::ckBoolOf(jResp,"org[i].mc_status")
gapps_enabled = CkJsonObject::ckBoolOf(jResp,"org[i].gapps_enabled")
domain_name = CkJsonObject::ckStringOf(jResp,"org[i].domain_name")
translation_enabled = CkJsonObject::ckBoolOf(jResp,"org[i].translation_enabled")
street = CkJsonObject::ckStringOf(jResp,"org[i].street")
alias = CkJsonObject::ckStringOf(jResp,"org[i].alias")
v_currency = CkJsonObject::ckStringOf(jResp,"org[i].currency")
id = CkJsonObject::ckStringOf(jResp,"org[i].id")
state = CkJsonObject::ckStringOf(jResp,"org[i].state")
fax = CkJsonObject::ckStringOf(jResp,"org[i].fax")
employee_count = CkJsonObject::ckStringOf(jResp,"org[i].employee_count")
zip = CkJsonObject::ckStringOf(jResp,"org[i].zip")
website = CkJsonObject::ckStringOf(jResp,"org[i].website")
currency_symbol = CkJsonObject::ckStringOf(jResp,"org[i].currency_symbol")
mobile = CkJsonObject::ckStringOf(jResp,"org[i].mobile")
currency_locale = CkJsonObject::ckStringOf(jResp,"org[i].currency_locale")
primary_zuid = CkJsonObject::ckStringOf(jResp,"org[i].primary_zuid")
zia_portal_id = CkJsonObject::ckStringOf(jResp,"org[i].zia_portal_id")
time_zone = CkJsonObject::ckStringOf(jResp,"org[i].time_zone")
zgid = CkJsonObject::ckStringOf(jResp,"org[i].zgid")
country_code = CkJsonObject::ckStringOf(jResp,"org[i].country_code")
Paid_expiry = CkJsonObject::ckStringOf(jResp,"org[i].license_details.paid_expiry")
Users_license_purchased = CkJsonObject::ckIntOf(jResp,"org[i].license_details.users_license_purchased")
Trial_type = CkJsonObject::ckStringOf(jResp,"org[i].license_details.trial_type")
Trial_expiry = CkJsonObject::ckStringOf(jResp,"org[i].license_details.trial_expiry")
Paid = CkJsonObject::ckBoolOf(jResp,"org[i].license_details.paid")
Paid_type = CkJsonObject::ckStringOf(jResp,"org[i].license_details.paid_type")
phone = CkJsonObject::ckStringOf(jResp,"org[i].phone")
company_name = CkJsonObject::ckStringOf(jResp,"org[i].company_name")
privacy_settings = CkJsonObject::ckBoolOf(jResp,"org[i].privacy_settings")
primary_email = CkJsonObject::ckStringOf(jResp,"org[i].primary_email")
iso_code = CkJsonObject::ckStringOf(jResp,"org[i].iso_code")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
-H "Authorization: {{authorization-token}}"
https://domain.com/crm/v2.1/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.1/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"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.1/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"org"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 04 May 2021 13:41:05 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "847"
},
{
"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-04T14:40:46+00:00"
},
{
"key": "clientVersion",
"value": "4004813"
},
{
"key": "clientsubVersion",
"value": "fb33599b767b94d06d2bd2529079b386"
},
{
"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 \"hierarchy_preferences\": {\n \"type\": \"Role_Hierarchy\"\n },\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\": false,\n \"primary_email\": \"patricia@zohocorp.com\",\n \"iso_code\": \"INR\"\n }\n ]\n}"
},
{
"name": "AUTHENTICATION_FAILURE",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
}
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"org"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 04 May 2021 12:36:48 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.1/org",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"org"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 04 May 2021 13:37:11 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}"
}
]
}