Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcDefault_value
LOCAL lcName
LOCAL lcPrefix
LOCAL j
LOCAL lnCount_j
LOCAL lcStrVal
LOCAL lcDashboard_id
LOCAL lcDashboard_type
LOCAL lcHandle
LOCAL lcName
LOCAL lcCreated_at
LOCAL lcLive_span
LOCAL lnGlobal_time_selectable_enabled
LOCAL lcPublic_url
LOCAL lcShare_type
LOCAL lcToken
LOCAL i
LOCAL lnCount_i
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
* "global_time": {
* "live_span": "1h"
* },
* "share_list": [
* "test@datadoghq.com",
* "test2@datadoghq.com"
* ],
* "share_type": "invite"
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("global_time.live_span","1h")
loJson.UpdateString("share_list[0]","test@datadoghq.com")
loJson.UpdateString("share_list[1]","test2@datadoghq.com")
loJson.UpdateString("share_type","invite")
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("Accept","application/json")
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbRequestBody = CreateObject('Chilkat.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PUT","https://api.app.ddog-gov.com/api/v1/dashboard/public/:token",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loResp.Header
? "Failed."
RELEASE loResp
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "dashboard_id": "123-abc-456",
* "dashboard_type": "custom_timeboard",
* "author": {
* "handle": "test@datadoghq.com",
* "name": "consequat irure sit"
* },
* "created_at": "2008-04-06T04:45:45.510Z",
* "global_time": {
* "live_span": "1h"
* },
* "global_time_selectable_enabled": false,
* "public_url": "fugiat esse mollit adipisicing",
* "selectable_template_vars": [
* {
* "default_value": "*",
* "name": "exampleVar",
* "prefix": "test",
* "visible_tags": [
* "selectableValue1",
* "selectableValue2"
* ]
* }
* ],
* "share_list": [
* "test@datadoghq.com",
* "test2@email.com"
* ],
* "share_type": "open",
* "token": "dolor fugiat consectetur ex"
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lcDashboard_id = loJResp.StringOf("dashboard_id")
lcDashboard_type = loJResp.StringOf("dashboard_type")
lcHandle = loJResp.StringOf("author.handle")
lcName = loJResp.StringOf("author.name")
lcCreated_at = loJResp.StringOf("created_at")
lcLive_span = loJResp.StringOf("global_time.live_span")
lnGlobal_time_selectable_enabled = loJResp.BoolOf("global_time_selectable_enabled")
lcPublic_url = loJResp.StringOf("public_url")
lcShare_type = loJResp.StringOf("share_type")
lcToken = loJResp.StringOf("token")
i = 0
lnCount_i = loJResp.SizeOfArray("selectable_template_vars")
DO WHILE i < lnCount_i
loJResp.I = i
lcDefault_value = loJResp.StringOf("selectable_template_vars[i].default_value")
lcName = loJResp.StringOf("selectable_template_vars[i].name")
lcPrefix = loJResp.StringOf("selectable_template_vars[i].prefix")
j = 0
lnCount_j = loJResp.SizeOfArray("selectable_template_vars[i].visible_tags")
DO WHILE j < lnCount_j
loJResp.J = j
lcStrVal = loJResp.StringOf("selectable_template_vars[i].visible_tags[j]")
j = j + 1
ENDDO
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("share_list")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("share_list[i]")
i = i + 1
ENDDO
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"global_time": {
"live_span": "1h"
},
"share_list": [
"test@datadoghq.com",
"test2@datadoghq.com"
],
"share_type": "invite"
}'
https://api.app.ddog-gov.com/api/v1/dashboard/public/:token
Postman Collection Item JSON
{
"name": "Update a shared dashboard",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@datadoghq.com\"\n ],\n \"share_type\": \"invite\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public",
":token"
],
"variable": [
{
"key": "token",
"value": "tempor Ut sed velit"
}
]
},
"description": "Update a shared dashboard associated with the specified token."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@datadoghq.com\"\n ],\n \"share_type\": \"invite\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public",
":token"
],
"variable": [
{
"key": "token"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"author\": {\n \"handle\": \"test@datadoghq.com\",\n \"name\": \"consequat irure sit\"\n },\n \"created_at\": \"2008-04-06T04:45:45.510Z\",\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"global_time_selectable_enabled\": false,\n \"public_url\": \"fugiat esse mollit adipisicing\",\n \"selectable_template_vars\": [\n {\n \"default_value\": \"*\",\n \"name\": \"exampleVar\",\n \"prefix\": \"test\",\n \"visible_tags\": [\n \"selectableValue1\",\n \"selectableValue2\"\n ]\n }\n ],\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@email.com\"\n ],\n \"share_type\": \"open\",\n \"token\": \"dolor fugiat consectetur ex\"\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@datadoghq.com\"\n ],\n \"share_type\": \"invite\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public",
":token"
],
"variable": [
{
"key": "token"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Authentication Error",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@datadoghq.com\"\n ],\n \"share_type\": \"invite\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public",
":token"
],
"variable": [
{
"key": "token"
}
]
}
},
"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": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@datadoghq.com\"\n ],\n \"share_type\": \"invite\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public",
":token"
],
"variable": [
{
"key": "token"
}
]
}
},
"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": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"global_time\": {\n \"live_span\": \"1h\"\n },\n \"share_list\": [\n \"test@datadoghq.com\",\n \"test2@datadoghq.com\"\n ],\n \"share_type\": \"invite\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public",
":token"
],
"variable": [
{
"key": "token"
}
]
}
},
"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}"
}
]
}