Back to Collection Items
use chilkat();
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
$http = chilkat::CkHttp->new();
# Use this online tool to generate code from sample JSON: Generate Code to Create JSON
# The following JSON is sent in the request body.
# {
# "dashboard_id": "123-abc-456",
# "dashboard_type": "custom_timeboard",
# "share_type": "open"
# }
$json = chilkat::CkJsonObject->new();
$json->UpdateString("dashboard_id","123-abc-456");
$json->UpdateString("dashboard_type","custom_timeboard");
$json->UpdateString("share_type","open");
$http->SetRequestHeader("Content-Type","application/json");
$http->SetRequestHeader("Accept","application/json");
# resp is a HttpResponse
$resp = $http->PostJson3("https://api.app.ddog-gov.com/api/v1/dashboard/public","application/json",$json);
if ($http->get_LastMethodSuccess() == 0) {
print $http->lastErrorText() . "\r\n";
exit;
}
$sbResponseBody = chilkat::CkStringBuilder->new();
$resp->GetBodySb($sbResponseBody);
$jResp = chilkat::CkJsonObject->new();
$jResp->LoadSb($sbResponseBody);
$jResp->put_EmitCompact(0);
print "Response Body:" . "\r\n";
print $jResp->emit() . "\r\n";
$respStatusCode = $resp->get_StatusCode();
print "Response Status Code = " . $respStatusCode . "\r\n";
if ($respStatusCode >= 400) {
print "Response Header:" . "\r\n";
print $resp->header() . "\r\n";
print "Failed." . "\r\n";
exit;
}
# 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
$dashboard_id = $jResp->stringOf("dashboard_id");
$dashboard_type = $jResp->stringOf("dashboard_type");
$Handle = $jResp->stringOf("author.handle");
$Name = $jResp->stringOf("author.name");
$created_at = $jResp->stringOf("created_at");
$Live_span = $jResp->stringOf("global_time.live_span");
$global_time_selectable_enabled = $jResp->BoolOf("global_time_selectable_enabled");
$public_url = $jResp->stringOf("public_url");
$share_type = $jResp->stringOf("share_type");
$token = $jResp->stringOf("token");
$i = 0;
$count_i = $jResp->SizeOfArray("selectable_template_vars");
while ($i < $count_i) {
$jResp->put_I($i);
$default_value = $jResp->stringOf("selectable_template_vars[i].default_value");
$name = $jResp->stringOf("selectable_template_vars[i].name");
$prefix = $jResp->stringOf("selectable_template_vars[i].prefix");
$j = 0;
$count_j = $jResp->SizeOfArray("selectable_template_vars[i].visible_tags");
while ($j < $count_j) {
$jResp->put_J($j);
$strVal = $jResp->stringOf("selectable_template_vars[i].visible_tags[j]");
$j = $j + 1;
}
$i = $i + 1;
}
$i = 0;
$count_i = $jResp->SizeOfArray("share_list");
while ($i < $count_i) {
$jResp->put_I($i);
$strVal = $jResp->stringOf("share_list[i]");
$i = $i + 1;
}
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"dashboard_id": "123-abc-456",
"dashboard_type": "custom_timeboard",
"share_type": "open"
}'
https://api.app.ddog-gov.com/api/v1/dashboard/public
Postman Collection Item JSON
{
"name": "Create a shared dashboard",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"share_type\": \"open\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public"
]
},
"description": "Share a specified private dashboard, generating a URL at which it can be publicly viewed."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "POST",
"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 \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"share_type\": \"open\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public"
]
}
},
"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": "POST",
"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 \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"share_type\": \"open\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public"
]
}
},
"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": "Forbidden",
"originalRequest": {
"method": "POST",
"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 \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"share_type\": \"open\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public"
]
}
},
"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": "Dashboard Not Found",
"originalRequest": {
"method": "POST",
"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 \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"share_type\": \"open\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public"
]
}
},
"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": "POST",
"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 \"dashboard_id\": \"123-abc-456\",\n \"dashboard_type\": \"custom_timeboard\",\n \"share_type\": \"open\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/public",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"public"
]
}
},
"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}"
}
]
}