Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *default_value;
const char *name;
const char *prefix;
int j;
int count_j;
const char *strVal;
const char *dashboard_id;
const char *dashboard_type;
const char *Handle;
const char *Name;
const char *created_at;
const char *Live_span;
BOOL global_time_selectable_enabled;
const char *public_url;
const char *share_type;
const char *token;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
CkHttp_SetRequestHeader(http,"Accept","application/json");
sbResponseBody = CkStringBuilder_Create();
success = CkHttp_QuickGetSb(http,"https://api.app.ddog-gov.com/api/v1/dashboard/public/:token",sbResponseBody);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttp_getLastStatus(http);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttp_lastHeader(http));
printf("Failed.\n");
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
// 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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
dashboard_id = CkJsonObject_stringOf(jResp,"dashboard_id");
dashboard_type = CkJsonObject_stringOf(jResp,"dashboard_type");
Handle = CkJsonObject_stringOf(jResp,"author.handle");
Name = CkJsonObject_stringOf(jResp,"author.name");
created_at = CkJsonObject_stringOf(jResp,"created_at");
Live_span = CkJsonObject_stringOf(jResp,"global_time.live_span");
global_time_selectable_enabled = CkJsonObject_BoolOf(jResp,"global_time_selectable_enabled");
public_url = CkJsonObject_stringOf(jResp,"public_url");
share_type = CkJsonObject_stringOf(jResp,"share_type");
token = CkJsonObject_stringOf(jResp,"token");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"selectable_template_vars");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
default_value = CkJsonObject_stringOf(jResp,"selectable_template_vars[i].default_value");
name = CkJsonObject_stringOf(jResp,"selectable_template_vars[i].name");
prefix = CkJsonObject_stringOf(jResp,"selectable_template_vars[i].prefix");
j = 0;
count_j = CkJsonObject_SizeOfArray(jResp,"selectable_template_vars[i].visible_tags");
while (j < count_j) {
CkJsonObject_putJ(jResp,j);
strVal = CkJsonObject_stringOf(jResp,"selectable_template_vars[i].visible_tags[j]");
j = j + 1;
}
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"share_list");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
strVal = CkJsonObject_stringOf(jResp,"share_list[i]");
i = i + 1;
}
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/dashboard/public/:token
Postman Collection Item JSON
{
"name": "Get a shared dashboard",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/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": "Fetch an existing shared dashboard's sharing metadata associated with the specified token."
},
"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/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": "Forbidden",
"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/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": "Shared Dashboard 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/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": "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/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}"
}
]
}