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
-- 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
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
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 @http, 'QuickGetSb', @success OUT, 'https://api.app.ddog-gov.com/api/v1/dashboard/:dashboard_id', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
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 @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "title": "",
-- "layout_type": "ordered",
-- "widgets": [
-- {
-- "definition": {
-- "type": "alert_graph",
-- "alert_id": "",
-- "viz_type": "timeseries",
-- "time": {
-- "live_span": "5m"
-- },
-- "title": "nisi et cupidatat sunt",
-- "title_align": "right",
-- "title_size": "officia anim occaecat aliq"
-- },
-- "id": 45068649,
-- "layout": {
-- "x": 0,
-- "y": 0,
-- "width": 0,
-- "height": 0,
-- "is_column_break": true
-- }
-- },
-- {
-- "definition": {
-- "type": "alert_graph",
-- "alert_id": "",
-- "viz_type": "timeseries",
-- "time": {
-- "live_span": "5m"
-- },
-- "title": "laborum dolor cillum ad",
-- "title_align": "center",
-- "title_size": "et"
-- },
-- "id": -40196020,
-- "layout": {
-- "x": 0,
-- "y": 0,
-- "width": 0,
-- "height": 0,
-- "is_column_break": false
-- }
-- }
-- ],
-- "author_handle": "test@datadoghq.com",
-- "author_name": "John Doe",
-- "created_at": "2017-08-17T07:10:36.438Z",
-- "description": "eiusmod do est velit enim",
-- "id": "123-abc-456",
-- "is_read_only": false,
-- "modified_at": "1996-07-08T08:32:43.112Z",
-- "notify_list": [
-- "commodo voluptate eu",
-- "consectetur amet"
-- ],
-- "reflow_type": "fixed",
-- "restricted_roles": [
-- "id cupidatat",
-- "quis ullamco"
-- ],
-- "tags": [
-- "quis qui mollit ex",
-- "ullamco enim cupidatat"
-- ],
-- "template_variable_presets": [
-- {
-- "name": "Lorem ex enim",
-- "template_variables": [
-- {
-- "name": "sed ",
-- "value": "quis eu",
-- "values": [
-- "in"
-- ]
-- },
-- {
-- "name": "non",
-- "value": "ea dolore esse elit Lorem",
-- "values": [
-- "sed voluptate nulla"
-- ]
-- }
-- ]
-- },
-- {
-- "name": "est ",
-- "template_variables": [
-- {
-- "name": "ullamco sint",
-- "value": "ad ex irure",
-- "values": [
-- "Duis elit dolor"
-- ]
-- },
-- {
-- "name": "proident adipisicing culpa cons",
-- "value": "occaecat",
-- "values": [
-- "esse fugiat"
-- ]
-- }
-- ]
-- }
-- ],
-- "template_variables": [
-- {
-- "name": "host1",
-- "available_values": [
-- "my-host",
-- "host1",
-- "host2"
-- ],
-- "default": "my-host",
-- "defaults": [
-- "my-host-1",
-- "my-host-2"
-- ],
-- "prefix": "host"
-- },
-- {
-- "name": "host1",
-- "available_values": [
-- "my-host",
-- "host1",
-- "host2"
-- ],
-- "default": "my-host",
-- "defaults": [
-- "my-host-1",
-- "my-host-2"
-- ],
-- "prefix": "host"
-- }
-- ],
-- "url": "/dashboard/123-abc-456/example-dashboard-title"
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @v_Type nvarchar(4000)
DECLARE @Alert_id nvarchar(4000)
DECLARE @Viz_type nvarchar(4000)
DECLARE @Live_span nvarchar(4000)
DECLARE @Title nvarchar(4000)
DECLARE @Title_align nvarchar(4000)
DECLARE @Title_size nvarchar(4000)
DECLARE @id_int int
DECLARE @X int
DECLARE @Y int
DECLARE @Width int
DECLARE @Height int
DECLARE @Is_column_break int
DECLARE @strVal nvarchar(4000)
DECLARE @name nvarchar(4000)
DECLARE @j int
DECLARE @count_j int
DECLARE @value nvarchar(4000)
DECLARE @k int
DECLARE @count_k int
DECLARE @default nvarchar(4000)
DECLARE @prefix nvarchar(4000)
DECLARE @title nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @title OUT, 'title'
DECLARE @layout_type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @layout_type OUT, 'layout_type'
DECLARE @author_handle nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @author_handle OUT, 'author_handle'
DECLARE @author_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @author_name OUT, 'author_name'
DECLARE @created_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'created_at'
DECLARE @description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'description'
DECLARE @id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
DECLARE @is_read_only int
EXEC sp_OAMethod @jResp, 'BoolOf', @is_read_only OUT, 'is_read_only'
DECLARE @modified_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @modified_at OUT, 'modified_at'
DECLARE @reflow_type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @reflow_type OUT, 'reflow_type'
DECLARE @url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @url OUT, 'url'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'widgets'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'widgets[i].definition.type'
EXEC sp_OAMethod @jResp, 'StringOf', @Alert_id OUT, 'widgets[i].definition.alert_id'
EXEC sp_OAMethod @jResp, 'StringOf', @Viz_type OUT, 'widgets[i].definition.viz_type'
EXEC sp_OAMethod @jResp, 'StringOf', @Live_span OUT, 'widgets[i].definition.time.live_span'
EXEC sp_OAMethod @jResp, 'StringOf', @Title OUT, 'widgets[i].definition.title'
EXEC sp_OAMethod @jResp, 'StringOf', @Title_align OUT, 'widgets[i].definition.title_align'
EXEC sp_OAMethod @jResp, 'StringOf', @Title_size OUT, 'widgets[i].definition.title_size'
EXEC sp_OAMethod @jResp, 'IntOf', @id_int OUT, 'widgets[i].id'
EXEC sp_OAMethod @jResp, 'IntOf', @X OUT, 'widgets[i].layout.x'
EXEC sp_OAMethod @jResp, 'IntOf', @Y OUT, 'widgets[i].layout.y'
EXEC sp_OAMethod @jResp, 'IntOf', @Width OUT, 'widgets[i].layout.width'
EXEC sp_OAMethod @jResp, 'IntOf', @Height OUT, 'widgets[i].layout.height'
EXEC sp_OAMethod @jResp, 'BoolOf', @Is_column_break OUT, 'widgets[i].layout.is_column_break'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'notify_list'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'notify_list[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'restricted_roles'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'restricted_roles[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'tags'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'tags[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'template_variable_presets'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'template_variable_presets[i].name'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'template_variable_presets[i].template_variables'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'template_variable_presets[i].template_variables[j].name'
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'template_variable_presets[i].template_variables[j].value'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'template_variable_presets[i].template_variables[j].values'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'template_variable_presets[i].template_variables[j].values[k]'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'template_variables'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'template_variables[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @default OUT, 'template_variables[i].default'
EXEC sp_OAMethod @jResp, 'StringOf', @prefix OUT, 'template_variables[i].prefix'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'template_variables[i].available_values'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'template_variables[i].available_values[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'template_variables[i].defaults'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'template_variables[i].defaults[j]'
SELECT @j = @j + 1
END
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 GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/dashboard/:dashboard_id
Postman Collection Item JSON
{
"name": "Get a dashboard",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/:dashboard_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
":dashboard_id"
],
"variable": [
{
"key": "dashboard_id",
"value": "tempor Ut sed velit"
}
]
},
"description": "Get a dashboard using the specified ID."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/:dashboard_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
":dashboard_id"
],
"variable": [
{
"key": "dashboard_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"title\": \"\",\n \"layout_type\": \"ordered\",\n \"widgets\": [\n {\n \"definition\": {\n \"type\": \"alert_graph\",\n \"alert_id\": \"\",\n \"viz_type\": \"timeseries\",\n \"time\": {\n \"live_span\": \"5m\"\n },\n \"title\": \"nisi et cupidatat sunt\",\n \"title_align\": \"right\",\n \"title_size\": \"officia anim occaecat aliq\"\n },\n \"id\": 45068649,\n \"layout\": {\n \"x\": 0,\n \"y\": 0,\n \"width\": 0,\n \"height\": 0,\n \"is_column_break\": true\n }\n },\n {\n \"definition\": {\n \"type\": \"alert_graph\",\n \"alert_id\": \"\",\n \"viz_type\": \"timeseries\",\n \"time\": {\n \"live_span\": \"5m\"\n },\n \"title\": \"laborum dolor cillum ad\",\n \"title_align\": \"center\",\n \"title_size\": \"et\"\n },\n \"id\": -40196020,\n \"layout\": {\n \"x\": 0,\n \"y\": 0,\n \"width\": 0,\n \"height\": 0,\n \"is_column_break\": false\n }\n }\n ],\n \"author_handle\": \"test@datadoghq.com\",\n \"author_name\": \"John Doe\",\n \"created_at\": \"2017-08-17T07:10:36.438Z\",\n \"description\": \"eiusmod do est velit enim\",\n \"id\": \"123-abc-456\",\n \"is_read_only\": false,\n \"modified_at\": \"1996-07-08T08:32:43.112Z\",\n \"notify_list\": [\n \"commodo voluptate eu\",\n \"consectetur amet\"\n ],\n \"reflow_type\": \"fixed\",\n \"restricted_roles\": [\n \"id cupidatat\",\n \"quis ullamco\"\n ],\n \"tags\": [\n \"quis qui mollit ex\",\n \"ullamco enim cupidatat\"\n ],\n \"template_variable_presets\": [\n {\n \"name\": \"Lorem ex enim\",\n \"template_variables\": [\n {\n \"name\": \"sed \",\n \"value\": \"quis eu\",\n \"values\": [\n \"in\"\n ]\n },\n {\n \"name\": \"non\",\n \"value\": \"ea dolore esse elit Lorem\",\n \"values\": [\n \"sed voluptate nulla\"\n ]\n }\n ]\n },\n {\n \"name\": \"est \",\n \"template_variables\": [\n {\n \"name\": \"ullamco sint\",\n \"value\": \"ad ex irure\",\n \"values\": [\n \"Duis elit dolor\"\n ]\n },\n {\n \"name\": \"proident adipisicing culpa cons\",\n \"value\": \"occaecat\",\n \"values\": [\n \"esse fugiat\"\n ]\n }\n ]\n }\n ],\n \"template_variables\": [\n {\n \"name\": \"host1\",\n \"available_values\": [\n \"my-host\",\n \"host1\",\n \"host2\"\n ],\n \"default\": \"my-host\",\n \"defaults\": [\n \"my-host-1\",\n \"my-host-2\"\n ],\n \"prefix\": \"host\"\n },\n {\n \"name\": \"host1\",\n \"available_values\": [\n \"my-host\",\n \"host1\",\n \"host2\"\n ],\n \"default\": \"my-host\",\n \"defaults\": [\n \"my-host-1\",\n \"my-host-2\"\n ],\n \"prefix\": \"host\"\n }\n ],\n \"url\": \"/dashboard/123-abc-456/example-dashboard-title\"\n}"
},
{
"name": "Authentication Error",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/:dashboard_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
":dashboard_id"
],
"variable": [
{
"key": "dashboard_id"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Item Not Found",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/:dashboard_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
":dashboard_id"
],
"variable": [
{
"key": "dashboard_id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Too many requests",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/:dashboard_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
":dashboard_id"
],
"variable": [
{
"key": "dashboard_id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
}
]
}