SQL Server / Squadcast API V3 / Get Incident Events
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
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'offset', 1
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 10
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'sort', 'asc'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'deduped', 'true'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.squadcast.com/v3/incidents/:incidentID/events', @queryParams
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 @queryParams
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 @queryParams
END
GO
Curl Command
curl -G -d "offset=1"
-d "limit=10"
-d "sort=asc"
-d "deduped=true"
-H "Authorization: Bearer <access_token>"
https://api.squadcast.com/v3/incidents/:incidentID/events
Postman Collection Item JSON
{
"name": "Get Incident Events",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{sq_pb_auth_header}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/incidents/:incidentID/events?offset=1&limit=10&sort=asc&deduped=true",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
":incidentID",
"events"
],
"query": [
{
"key": "offset",
"value": "1",
"description": "non zero value"
},
{
"key": "limit",
"value": "10",
"description": "non zero value, maximum is 10"
},
{
"key": "sort",
"value": "asc",
"description": "sort it by either asc or desc"
},
{
"key": "deduped",
"value": "true",
"description": "if set to true, it will return only the deduped events.\n\nif set to false, it will return only the non-deduped event.\n\notherwise it will return all the events"
}
],
"variable": [
{
"key": "incidentID",
"value": "5d81d9bc60e42f6b99ca4307"
}
]
},
"description": "- This endpoint is used to get all the deduped incident events details by either ID or number.\n- Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header.\n\nQuery Params:\n```\noffset - non zero value\nlimit - non zero value, maximum is 10\nsort - sort it by either asc or desc\ndeduped - if set to true, it will return only the deduplicated events. if set to false, it will return only the non-deduplicated event, otherwise it will return all the events\n```"
},
"response": [
{
"name": "200 OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/incidents/:incidentID/events?offset=1&limit=10&sort=asc&deduped=true",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
":incidentID",
"events"
],
"query": [
{
"key": "offset",
"value": "1"
},
{
"key": "limit",
"value": "10"
},
{
"key": "sort",
"value": "asc"
},
{
"key": "deduped",
"value": "true"
}
],
"variable": [
{
"key": "incidentID",
"value": "5f6480a22379e9c06df6a32e"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"data\": {\n \"events\": [\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:02.721Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:02.401Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:02.088Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:01.769Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:01.454Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:01.091Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:00.689Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:41:00.24Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n },\n {\n \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"time_of_creation\": \"2020-09-18T09:40:59.689Z\",\n \"tags\": null,\n \"deduplication_reason\": {\n \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n \"evaluated_expression\": \"true\",\n \"time_window\": 3600\n },\n \"payload\": {\n \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n \"event_id\": \"6\",\n \"message\": \"Memory out of set threshold : 70.1%\",\n \"metric\": {\n \"absolute\": {\n \"current_value\": 1.402,\n \"threshold\": 1.4,\n \"unit\": \"GB\"\n },\n \"pod\": \"platform-d23ixi-ug5ty\",\n \"relative\": {\n \"current_value\": 70.1,\n \"threshold\": 70\n },\n \"time\": \"2020-09-18T09:37:13.607Z\"\n },\n \"status\": \"trigger\"\n }\n }\n ]\n },\n \"meta\": {\n \"total\": 20,\n \"count\": 10,\n \"current\": \"https://api.squadcast.com/v3/incidents/5f6480a22379e9c06df6a32e/events?offset=0&limit=10&deduped=true\",\n \"next\": \"https://api.squadcast.com/v3/incidents/5f6480a22379e9c06df6a32e/events?deduped=true&limit=10&offset=10\"\n }\n}"
},
{
"name": "401 Unauthorized",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/incidents/:incidentID/events?offset=1&limit=1",
"host": [
"{{baseUrl}}"
],
"path": [
"incidents",
":incidentID",
"events"
],
"query": [
{
"key": "offset",
"value": "1"
},
{
"key": "limit",
"value": "1"
}
],
"variable": [
{
"key": "incidentID",
"value": "5d81d9bc60e42f6b99ca4305"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 401,\n \"error_message\": \"<string>\"\n }\n}"
}
]
}