SQL Server / Zoho CRM REST APIs / Disable Notifications
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequest', @resp OUT, 'DELETE', 'https://domain.com/crm/v2/actions/watch?channel_ids=1000000068003,1000000068001,1000000068002'
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "watch": [
-- {
-- "code": "SUCCESS",
-- "details": {
-- "resource_uri": "https://crm.localzoho.com/crm/v2/Cases",
-- "resource_id": "738964000000000159",
-- "channel_id": "1000000068003"
-- },
-- "message": "Successfully un-subscribed from actions-watch",
-- "status": "success"
-- },
-- {
-- "code": "SUCCESS",
-- "details": {
-- "resource_uri": "https://crm.localzoho.com/crm/v2/Contacts",
-- "resource_id": "738964000000000129",
-- "channel_id": "1000000068001"
-- },
-- "message": "Successfully un-subscribed from actions-watch",
-- "status": "success"
-- },
-- {
-- "code": "SUCCESS",
-- "details": {
-- "resource_uri": "https://crm.localzoho.com/crm/v2/Solutions",
-- "resource_id": "738964000000000161",
-- "channel_id": "1000000068001"
-- },
-- "message": "Successfully un-subscribed from actions-watch",
-- "status": "success"
-- },
-- {
-- "code": "SUCCESS",
-- "details": {
-- "resource_uri": "https://crm.localzoho.com/crm/v2/Price_Books",
-- "resource_id": "738964000000000167",
-- "channel_id": "1000000068001"
-- },
-- "message": "Successfully un-subscribed from actions-watch",
-- "status": "success"
-- },
-- {
-- "code": "SUCCESS",
-- "details": {
-- "resource_uri": "https://crm.localzoho.com/crm/v2/Deals",
-- "resource_id": "738964000000000131",
-- "channel_id": "1000000068002"
-- },
-- "message": "Successfully un-subscribed from actions-watch",
-- "status": "success"
-- }
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @code nvarchar(4000)
DECLARE @Resource_uri nvarchar(4000)
DECLARE @Resource_id nvarchar(4000)
DECLARE @Channel_id nvarchar(4000)
DECLARE @message nvarchar(4000)
DECLARE @status nvarchar(4000)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'watch'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @code OUT, 'watch[i].code'
EXEC sp_OAMethod @jResp, 'StringOf', @Resource_uri OUT, 'watch[i].details.resource_uri'
EXEC sp_OAMethod @jResp, 'StringOf', @Resource_id OUT, 'watch[i].details.resource_id'
EXEC sp_OAMethod @jResp, 'StringOf', @Channel_id OUT, 'watch[i].details.channel_id'
EXEC sp_OAMethod @jResp, 'StringOf', @message OUT, 'watch[i].message'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'watch[i].status'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X DELETE
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2/actions/watch?channel_ids=1000000068003,1000000068001,1000000068002
Postman Collection Item JSON
{
"name": "Disable Notifications",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch?channel_ids=1000000068003,1000000068001,1000000068002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
],
"query": [
{
"key": "channel_ids",
"value": "1000000068003,1000000068001,1000000068002"
}
]
},
"description": "To stop all the instant notifications enabled by the user for a channel."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch?channel_ids=1000000068003,1000000068001,1000000068002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
],
"query": [
{
"key": "channel_ids",
"value": "1000000068003,1000000068001,1000000068002"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:49:27 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 \"code\": \"SUCCESS\",\n \"details\": {\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Cases\",\n \"resource_id\": \"738964000000000159\",\n \"channel_id\": \"1000000068003\"\n },\n \"message\": \"Successfully un-subscribed from actions-watch\",\n \"status\": \"success\"\n },\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Contacts\",\n \"resource_id\": \"738964000000000129\",\n \"channel_id\": \"1000000068001\"\n },\n \"message\": \"Successfully un-subscribed from actions-watch\",\n \"status\": \"success\"\n },\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Solutions\",\n \"resource_id\": \"738964000000000161\",\n \"channel_id\": \"1000000068001\"\n },\n \"message\": \"Successfully un-subscribed from actions-watch\",\n \"status\": \"success\"\n },\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Price_Books\",\n \"resource_id\": \"738964000000000167\",\n \"channel_id\": \"1000000068001\"\n },\n \"message\": \"Successfully un-subscribed from actions-watch\",\n \"status\": \"success\"\n },\n {\n \"code\": \"SUCCESS\",\n \"details\": {\n \"resource_uri\": \"https://crm.localzoho.com/crm/v2/Deals\",\n \"resource_id\": \"738964000000000131\",\n \"channel_id\": \"1000000068002\"\n },\n \"message\": \"Successfully un-subscribed from actions-watch\",\n \"status\": \"success\"\n }\n ]\n}"
},
{
"name": "REQUIRED_PARAM_MISSING",
"originalRequest": {
"method": "DELETE",
"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": "Tue, 11 May 2021 15:49:51 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "138"
},
{
"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": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"REQUIRED_PARAM_MISSING\",\n \"details\": {\n \"param\": \"channel_ids\"\n },\n \"message\": \"One of the expected parameter is missing\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watc?channel_ids=1000000068003,1000000068001,1000000068002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watc"
],
"query": [
{
"key": "channel_ids",
"value": "1000000068003,1000000068001,1000000068002"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:50:14 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": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch?channel_ids=1000000068003,1000000068001,1000000068002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
],
"query": [
{
"key": "channel_ids",
"value": "1000000068003,1000000068001,1000000068002"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:50:36 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/watch?channel_ids=1000000068003,1000000068001,1000000068002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
],
"query": [
{
"key": "channel_ids",
"value": "1000000068003,1000000068001,1000000068002"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 15:50:49 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": "DELETE",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/actions/watch?channel_ids=1000000068003,1000000068001,1000000068002",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"actions",
"watch"
],
"query": [
{
"key": "channel_ids",
"value": "1000000068003,1000000068001,1000000068002"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Thu, 13 May 2021 06:48:37 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}"
}
]
}