Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
Boolean iNotify_on_related_action
String sChannel_expiry
String sResource_uri
String sResource_id
String sNotify_url
String sResource_name
String sChannel_id
String sToken
Integer j
Integer iCount_j
String sStrVal
Integer iPer_page
Integer iCount
Integer iPage
Boolean iMore_records
Integer i
Integer iCount_i
String sTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Adds the "Authorization: Bearer <access_token>" header.
Set ComAuthToken Of hoHttp To "<access_token>"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://domain.com/crm/v2/actions/watch" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "watch": [
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:44:10+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Contacts",
// "resource_id": "738964000000000129",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2",
// "resource_name": "Contacts",
// "channel_id": "1000000068001",
// "events": [
// "Contacts.create"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_100000006800"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:44:10+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Solutions",
// "resource_id": "738964000000000161",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2",
// "resource_name": "Solutions",
// "channel_id": "1000000068001",
// "events": [
// "Solutions.edit",
// "Solutions.create"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_100000006800"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:44:10+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Price_Books",
// "resource_id": "738964000000000167",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2",
// "resource_name": "Price_Books",
// "channel_id": "1000000068001",
// "events": [
// "Price_Books.create"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_100000006800"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:43:19+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Deals",
// "resource_id": "738964000000000131",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2&key3=val1",
// "resource_name": "Deals",
// "channel_id": "1000000068002",
// "events": [
// "Deals.edit",
// "Deals.create",
// "Deals.delete"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_1000000068002"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:43:19+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Cases",
// "resource_id": "738964000000000159",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1",
// "resource_name": "Cases",
// "channel_id": "1000000068003",
// "events": [
// "Cases.edit",
// "Cases.create",
// "Cases.delete"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_1000000068003"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:43:19+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Contacts",
// "resource_id": "738964000000000129",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2",
// "resource_name": "Contacts",
// "channel_id": "123",
// "events": [
// "Contacts.create"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_1000000068001"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:43:19+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Solutions",
// "resource_id": "738964000000000161",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2",
// "resource_name": "Solutions",
// "channel_id": "123",
// "events": [
// "Solutions.edit",
// "Solutions.create"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_1000000068001"
// },
// {
// "notify_on_related_action": true,
// "channel_expiry": "2021-05-11T16:43:19+00:00",
// "resource_uri": "https://crm.localzoho.com/crm/v2/Price_Books",
// "resource_id": "738964000000000167",
// "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2",
// "resource_name": "Price_Books",
// "channel_id": "123",
// "events": [
// "Price_Books.create"
// ],
// "token": "TOKEN_FOR_VERIFICATION_OF_1000000068001"
// }
// ],
// "info": {
// "per_page": 200,
// "count": 8,
// "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
Get ComIntOf Of hoJResp "info.per_page" To iPer_page
Get ComIntOf Of hoJResp "info.count" To iCount
Get ComIntOf Of hoJResp "info.page" To iPage
Get ComBoolOf Of hoJResp "info.more_records" To iMore_records
Move 0 To i
Get ComSizeOfArray Of hoJResp "watch" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComBoolOf Of hoJResp "watch[i].notify_on_related_action" To iNotify_on_related_action
Get ComStringOf Of hoJResp "watch[i].channel_expiry" To sChannel_expiry
Get ComStringOf Of hoJResp "watch[i].resource_uri" To sResource_uri
Get ComStringOf Of hoJResp "watch[i].resource_id" To sResource_id
Get ComStringOf Of hoJResp "watch[i].notify_url" To sNotify_url
Get ComStringOf Of hoJResp "watch[i].resource_name" To sResource_name
Get ComStringOf Of hoJResp "watch[i].channel_id" To sChannel_id
Get ComStringOf Of hoJResp "watch[i].token" To sToken
Move 0 To j
Get ComSizeOfArray Of hoJResp "watch[i].events" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComStringOf Of hoJResp "watch[i].events[j]" To sStrVal
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
End_Procedure
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2/actions/watch
Postman Collection Item JSON
{
"name": "Notification Details",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
]
},
"description": "To get the details of the notifications enabled by the user."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15: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-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-11T16:40:31+00:00"
},
{
"key": "clientVersion",
"value": "4027076"
},
{
"key": "clientsubVersion",
"value": "748ecbe82ec7e144b66ee25f264bbd88"
},
{
"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 \"watch\": [\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:44:10+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Contacts\",\n \"resource_id\": \"738964000000000129\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2\",\n \"resource_name\": \"Contacts\",\n \"channel_id\": \"1000000068001\",\n \"events\": [\n \"Contacts.create\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_100000006800\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:44:10+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Solutions\",\n \"resource_id\": \"738964000000000161\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2\",\n \"resource_name\": \"Solutions\",\n \"channel_id\": \"1000000068001\",\n \"events\": [\n \"Solutions.edit\",\n \"Solutions.create\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_100000006800\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:44:10+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Price_Books\",\n \"resource_id\": \"738964000000000167\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2\",\n \"resource_name\": \"Price_Books\",\n \"channel_id\": \"1000000068001\",\n \"events\": [\n \"Price_Books.create\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_100000006800\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:43:19+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Deals\",\n \"resource_id\": \"738964000000000131\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2&key3=val1\",\n \"resource_name\": \"Deals\",\n \"channel_id\": \"1000000068002\",\n \"events\": [\n \"Deals.edit\",\n \"Deals.create\",\n \"Deals.delete\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_1000000068002\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:43:19+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Cases\",\n \"resource_id\": \"738964000000000159\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1\",\n \"resource_name\": \"Cases\",\n \"channel_id\": \"1000000068003\",\n \"events\": [\n \"Cases.edit\",\n \"Cases.create\",\n \"Cases.delete\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_1000000068003\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:43:19+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Contacts\",\n \"resource_id\": \"738964000000000129\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2\",\n \"resource_name\": \"Contacts\",\n \"channel_id\": \"123\",\n \"events\": [\n \"Contacts.create\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_1000000068001\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:43:19+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Solutions\",\n \"resource_id\": \"738964000000000161\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2\",\n \"resource_name\": \"Solutions\",\n \"channel_id\": \"123\",\n \"events\": [\n \"Solutions.edit\",\n \"Solutions.create\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_1000000068001\"\n },\n {\n \"notify_on_related_action\": true,\n \"channel_expiry\": \"2021-05-11T16:43:19+00:00\",\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Price_Books\",\n \"resource_id\": \"738964000000000167\",\n \"notify_url\": \"https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2\",\n \"resource_name\": \"Price_Books\",\n \"channel_id\": \"123\",\n \"events\": [\n \"Price_Books.create\"\n ],\n \"token\": \"TOKEN_FOR_VERIFICATION_OF_1000000068001\"\n }\n ],\n \"info\": {\n \"per_page\": 200,\n \"count\": 8,\n \"page\": 1,\n \"more_records\": false\n }\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watc",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watc"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:45:51 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "131"
},
{
"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-11T16:40:31+00:00"
},
{
"key": "Set-Cookie",
"value": "JSESSIONID=4F4521EC75D7E3DBAC688347E8B91ECF; Path=/; Secure"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_URL_PATTERN\",\n \"details\": {},\n \"message\": \"Please check if the URL trying to access is a correct one\",\n \"status\": \"error\"\n}"
},
{
"name": "AUTHENTICATION_FAILURE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watc",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watc"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:46:11 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": "INVALID_REQUEST_METHOD",
"originalRequest": {
"method": "COPY",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watc",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watc"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:46:38 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": "INVALID_REQUEST",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Thu, 13 May 2021 06:48:01 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "192"
},
{
"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\": \"INVALID_REQUEST\",\n \"details\": {},\n \"message\": \"unable to process your request. please verify whether you have entered proper method name, parameter and parameter values.\",\n \"status\": \"error\"\n}"
}
]
}