SQL Server / Squadcast API V3 / Bulk Resolve Incidents
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
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "incident_ids": [
-- "5f04e3a08fada03f23aac811",
-- "5f04e3a08fada03f23aac812",
-- "5f04e3a08fada03f23aac813"
-- ]
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'incident_ids[0]', '5f04e3a08fada03f23aac811'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'incident_ids[1]', '5f04e3a08fada03f23aac812'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'incident_ids[2]', '5f04e3a08fada03f23aac813'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://api.squadcast.com/v3/incidents/resolve', 'application/json', @json
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
EXEC @hr = sp_OADestroy @json
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
END
GO
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"incident_ids": [
"5f04e3a08fada03f23aac811",
"5f04e3a08fada03f23aac812",
"5f04e3a08fada03f23aac813"
]
}'
https://api.squadcast.com/v3/incidents/resolve
Postman Collection Item JSON
{
"name": "Bulk Resolve Incidents",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{sq_pb_auth_header}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"incident_ids\": [\n \"5f04e3a08fada03f23aac811\",\n \"5f04e3a08fada03f23aac812\",\n \"5f04e3a08fada03f23aac813\"\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/incidents/resolve",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
"resolve"
]
},
"description": "- This endpoint is used to bulk resolve the incident by IDs.\n- Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header."
},
"response": [
{
"name": "200 OK",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"incident_ids\": [\n \"5f04e3a08fada03f23aac811\",\n \"5f04e3a08fada03f23aac812\",\n \"5f04e3a08fada03f23aac813\"\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/incidents/resolve",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
"resolve"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"data\": \"all incident successfully resolved\"\n}"
},
{
"name": "400 Bad Request",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"incident_ids\": [\n \"5f04e3a08fada03f23aac811\",\n \"5f04e3a08fada03f23aac812\",\n \"5f04e3a08fada03f23aac813\"\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/incidents/resolve",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
"resolve"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 400,\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "401 Unauthorized",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"incident_ids\": [\n \"5f04e3a08fada03f23aac811\",\n \"5f04e3a08fada03f23aac812\",\n \"5f04e3a08fada03f23aac813\"\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/incidents/resolve",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
"resolve"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 401,\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "403 Forbidden",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"incident_ids\": [\n \"5f04e3a08fada03f23aac811\",\n \"5f04e3a08fada03f23aac812\",\n \"5f04e3a08fada03f23aac813\"\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/incidents/resolve",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
"resolve"
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 403,\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "500 Internal Server Error",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"incident_ids\": [\n \"5f04e3a08fada03f23aac811\",\n \"5f04e3a08fada03f23aac812\",\n \"5f04e3a08fada03f23aac813\"\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/incidents/resolve",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
"resolve"
]
}
},
"status": "Internal Server Error",
"code": 500,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 500,\n \"error_message\": \"<string>\"\n }\n}"
}
]
}