Chilkat Online Tools

C# / Zoho CRM REST APIs / Disable Specific Notifications

Back to Collection Items

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

Chilkat.Http http = new Chilkat.Http();
bool success;

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "watch": [
//     {
//       "channel_id": "1000000058001",
//       "events": [
//         "Leads.edit",
//         "Cases.all"
//       ],
//       "_delete_events": true
//     }
//   ]
// }

Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("watch[0].channel_id","1000000058001");
json.UpdateString("watch[0].events[0]","Leads.edit");
json.UpdateString("watch[0].events[1]","Cases.all");
json.UpdateBool("watch[0]._delete_events",true);

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

Chilkat.StringBuilder sbRequestBody = new Chilkat.StringBuilder();
json.EmitSb(sbRequestBody);

Chilkat.HttpResponse resp = http.PTextSb("PATCH","https://domain.com/crm/v2/actions/watch",sbRequestBody,"utf-8","application/json",false,false);
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);

Chilkat.JsonObject jResp = new Chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;

Debug.WriteLine("Response Body:");
Debug.WriteLine(jResp.Emit());

int respStatusCode = resp.StatusCode;
Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
if (respStatusCode >= 400) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(resp.Header);
    Debug.WriteLine("Failed.");

    return;
}

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

// {
//   "watch": [
//     {
//       "code": "NOT_SUBSCRIBED",
//       "details": {},
//       "message": "Not subscribed for actions-watch of the given channel",
//       "status": "error"
//     }
//   ]
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

string code;
string message;
string status;

int i = 0;
int count_i = jResp.SizeOfArray("watch");
while (i < count_i) {
    jResp.I = i;
    code = jResp.StringOf("watch[i].code");
    message = jResp.StringOf("watch[i].message");
    status = jResp.StringOf("watch[i].status");
    i = i + 1;
}

Curl Command

curl -X PATCH
	-H "Authorization: Bearer <access_token>"
	-d '{
    "watch": [
       {
            "channel_id": "1000000058001",
            "events": [
                "Leads.edit",
                "Cases.all"
            ],
            "_delete_events": true
        }
    ]
}'
https://domain.com/crm/v2/actions/watch

Postman Collection Item JSON

{
  "name": "Disable Specific Notifications",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{access-token}}",
          "type": "string"
        }
      ]
    },
    "method": "PATCH",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"watch\": [\n       {\n            \"channel_id\": \"1000000058001\",\n            \"events\": [\n                \"Leads.edit\",\n                \"Cases.all\"\n            ],\n            \"_delete_events\": true\n        }\n    ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{api-domain}}/crm/v2/actions/watch",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2",
        "actions",
        "watch"
      ]
    },
    "description": "To disable notifications for the specified events in a channel."
  },
  "response": [
    {
      "name": "NOT_SUBSCRIBED",
      "originalRequest": {
        "method": "PATCH",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"watch\": [\n       {\n            \"channel_id\": \"1000000058001\",\n            \"events\": [\n                \"Leads.edit\",\n                \"Cases.all\"\n            ],\n            \"_delete_events\": true\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{api-domain}}/crm/v2/actions/watch",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2",
            "actions",
            "watch"
          ]
        }
      },
      "status": "Accepted",
      "code": 202,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 15:51:09 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "133"
        },
        {
          "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": "Content-Language",
          "value": "en-US"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"watch\": [\n        {\n            \"code\": \"NOT_SUBSCRIBED\",\n            \"details\": {},\n            \"message\": \"Not subscribed for actions-watch of the given channel\",\n            \"status\": \"error\"\n        }\n    ]\n}"
    },
    {
      "name": "INVALID_URL_PATTERN",
      "originalRequest": {
        "method": "PATCH",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"watch\": [\n       {\n            \"channel_id\": \"1000000058001\",\n            \"events\": [\n                \"Leads.edit\",\n                \"Cases.all\"\n            ],\n            \"_delete_events\": true\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "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:51:25 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": "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": "PATCH",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"watch\": [\n       {\n            \"channel_id\": \"1000000058001\",\n            \"events\": [\n                \"Leads.edit\",\n                \"Cases.all\"\n            ],\n            \"_delete_events\": true\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "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:51:39 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": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"watch\": [\n       {\n            \"channel_id\": \"1000000058001\",\n            \"events\": [\n                \"Leads.edit\",\n                \"Cases.all\"\n            ],\n            \"_delete_events\": true\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "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:51:57 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": "PATCH",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"watch\": [\n       {\n            \"channel_id\": \"1000000058001\",\n            \"events\": [\n                \"Leads.edit\",\n                \"Cases.all\"\n            ],\n            \"_delete_events\": true\n        }\n    ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "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:47 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}"
    }
  ]
}