Chilkat Online Tools

PowerBuilder / Zoho CRM REST APIs / Notification Details

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
integer li_Notify_on_related_action
string ls_Channel_expiry
string ls_Resource_uri
string ls_Resource_id
string ls_Notify_url
string ls_Resource_name
string ls_Channel_id
string ls_Token
integer j
integer li_Count_j
string ls_StrVal
integer li_Per_page
integer li_Count
integer li_Page
integer li_More_records
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://domain.com/crm/v2.1/actions/watch",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "watch": [
//     {
//       "notify_on_related_action": true,
//       "channel_expiry": "2021-05-11T15:01:32+05:30",
//       "resource_uri": "https://www.zohoapis.com/crm/v2/Contacts",
//       "resource_id": "4150868000000002179",
//       "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_1000000068001"
//     },
//     {
//       "notify_on_related_action": true,
//       "channel_expiry": "2021-05-11T15:01:32+05:30",
//       "resource_uri": "https://www.zohoapis.com/crm/v2/Solutions",
//       "resource_id": "4150868000000002211",
//       "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_1000000068001"
//     },
//     {
//       "notify_on_related_action": true,
//       "channel_expiry": "2021-05-11T15:01:32+05:30",
//       "resource_uri": "https://www.zohoapis.com/crm/v2/Price_Books",
//       "resource_id": "4150868000000002217",
//       "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_1000000068001"
//     },
//     {
//       "notify_on_related_action": true,
//       "channel_expiry": "2021-05-11T15:01:32+05:30",
//       "resource_uri": "https://www.zohoapis.com/crm/v2/Deals",
//       "resource_id": "4150868000000002181",
//       "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-11T15:01:32+05:30",
//       "resource_uri": "https://www.zohoapis.com/crm/v2/Cases",
//       "resource_id": "4150868000000002209",
//       "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"
//     }
//   ],
//   "info": {
//     "per_page": 200,
//     "count": 5,
//     "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

li_Per_page = loo_JResp.IntOf("info.per_page")
li_Count = loo_JResp.IntOf("info.count")
li_Page = loo_JResp.IntOf("info.page")
li_More_records = loo_JResp.BoolOf("info.more_records")
i = 0
li_Count_i = loo_JResp.SizeOfArray("watch")
do while i < li_Count_i
    loo_JResp.I = i
    li_Notify_on_related_action = loo_JResp.BoolOf("watch[i].notify_on_related_action")
    ls_Channel_expiry = loo_JResp.StringOf("watch[i].channel_expiry")
    ls_Resource_uri = loo_JResp.StringOf("watch[i].resource_uri")
    ls_Resource_id = loo_JResp.StringOf("watch[i].resource_id")
    ls_Notify_url = loo_JResp.StringOf("watch[i].notify_url")
    ls_Resource_name = loo_JResp.StringOf("watch[i].resource_name")
    ls_Channel_id = loo_JResp.StringOf("watch[i].channel_id")
    ls_Token = loo_JResp.StringOf("watch[i].token")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("watch[i].events")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("watch[i].events[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2.1/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.1/actions/watch",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2.1",
        "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.1/actions/watch",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "actions",
            "watch"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:31:35 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-11T14:00:30+05:30"
        },
        {
          "key": "clientVersion",
          "value": "4019232"
        },
        {
          "key": "clientsubVersion",
          "value": "19804a82a902c9fa618d2b359b97e26a"
        },
        {
          "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=63072000"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"watch\": [\n        {\n            \"notify_on_related_action\": true,\n            \"channel_expiry\": \"2021-05-11T15:01:32+05:30\",\n            \"resource_uri\": \"https://www.zohoapis.com/crm/v2/Contacts\",\n            \"resource_id\": \"4150868000000002179\",\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_1000000068001\"\n        },\n        {\n            \"notify_on_related_action\": true,\n            \"channel_expiry\": \"2021-05-11T15:01:32+05:30\",\n            \"resource_uri\": \"https://www.zohoapis.com/crm/v2/Solutions\",\n            \"resource_id\": \"4150868000000002211\",\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_1000000068001\"\n        },\n        {\n            \"notify_on_related_action\": true,\n            \"channel_expiry\": \"2021-05-11T15:01:32+05:30\",\n            \"resource_uri\": \"https://www.zohoapis.com/crm/v2/Price_Books\",\n            \"resource_id\": \"4150868000000002217\",\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_1000000068001\"\n        },\n        {\n            \"notify_on_related_action\": true,\n            \"channel_expiry\": \"2021-05-11T15:01:32+05:30\",\n            \"resource_uri\": \"https://www.zohoapis.com/crm/v2/Deals\",\n            \"resource_id\": \"4150868000000002181\",\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-11T15:01:32+05:30\",\n            \"resource_uri\": \"https://www.zohoapis.com/crm/v2/Cases\",\n            \"resource_id\": \"4150868000000002209\",\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    \"info\": {\n        \"per_page\": 200,\n        \"count\": 5,\n        \"page\": 1,\n        \"more_records\": false\n    }\n}"
    },
    {
      "name": "INVALID_URL_PATTERN",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/actions/watc",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "actions",
            "watc"
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:31:58 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-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-11T14:00:30+05:30"
        },
        {
          "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.1/actions/watch",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "actions",
            "watch"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:37:41 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.1/actions/watch",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "actions",
            "watch"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:38:58 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": "OAUTH_SCOPE_MISMATCH",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/v2.1/actions/watch",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2.1",
            "actions",
            "watch"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Thu, 13 May 2021 08:25:13 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}"
    }
  ]
}