Back to Collection Items
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "name": "My Dashboard",
// "author": {
// "email": "Excepteur id tempor cillum",
// "handle": "culpa nostrud pariatur",
// "name": "cillum minim"
// },
// "created": "1966-02-10T07:56:34.100Z",
// "dashboard_count": 38191328,
// "id": 17219875,
// "is_favorite": false,
// "modified": "1943-12-25T04:37:37.575Z",
// "type": "manual_dashboard_list"
// }
$json = new CkJsonObject();
$json->UpdateString('name','My Dashboard');
$json->UpdateString('author.email','Excepteur id tempor cillum');
$json->UpdateString('author.handle','culpa nostrud pariatur');
$json->UpdateString('author.name','cillum minim');
$json->UpdateString('created','1966-02-10T07:56:34.100Z');
$json->UpdateInt('dashboard_count',38191328);
$json->UpdateInt('id',17219875);
$json->UpdateBool('is_favorite',false);
$json->UpdateString('modified','1943-12-25T04:37:37.575Z');
$json->UpdateString('type','manual_dashboard_list');
$http->SetRequestHeader('Content-Type','application/json');
$http->SetRequestHeader('Accept','application/json');
// resp is a CkHttpResponse
$resp = $http->PostJson3('https://api.app.ddog-gov.com/api/v1/dashboard/lists/manual','application/json',$json);
if ($http->get_LastMethodSuccess() == false) {
print $http->lastErrorText() . "\n";
exit;
}
$sbResponseBody = new CkStringBuilder();
$resp->GetBodySb($sbResponseBody);
$jResp = new CkJsonObject();
$jResp->LoadSb($sbResponseBody);
$jResp->put_EmitCompact(false);
print 'Response Body:' . "\n";
print $jResp->emit() . "\n";
$respStatusCode = $resp->get_StatusCode();
print 'Response Status Code = ' . $respStatusCode . "\n";
if ($respStatusCode >= 400) {
print 'Response Header:' . "\n";
print $resp->header() . "\n";
print 'Failed.' . "\n";
exit;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "name": "My Dashboard",
// "author": {
// "email": "Excepteur id tempor cillum",
// "handle": "culpa nostrud pariatur",
// "name": "cillum minim"
// },
// "created": "1966-02-10T07:56:34.100Z",
// "dashboard_count": 38191328,
// "id": 17219875,
// "is_favorite": false,
// "modified": "1943-12-25T04:37:37.575Z",
// "type": "manual_dashboard_list"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
$name = $jResp->stringOf('name');
$v_Email = $jResp->stringOf('author.email');
$Handle = $jResp->stringOf('author.handle');
$Name = $jResp->stringOf('author.name');
$created = $jResp->stringOf('created');
$dashboard_count = $jResp->IntOf('dashboard_count');
$id = $jResp->IntOf('id');
$is_favorite = $jResp->BoolOf('is_favorite');
$modified = $jResp->stringOf('modified');
$v_type = $jResp->stringOf('type');
?>
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"name": "My Dashboard",
"author": {
"email": "Excepteur id tempor cillum",
"handle": "culpa nostrud pariatur",
"name": "cillum minim"
},
"created": "1966-02-10T07:56:34.100Z",
"dashboard_count": 38191328,
"id": 17219875,
"is_favorite": false,
"modified": "1943-12-25T04:37:37.575Z",
"type": "manual_dashboard_list"
}'
https://api.app.ddog-gov.com/api/v1/dashboard/lists/manual
Postman Collection Item JSON
{
"name": "Create a dashboard list",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual"
]
},
"description": "Create an empty dashboard list."
},
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual"
]
}
},
"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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual"
]
}
},
"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": "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 \"name\": \"My Dashboard\",\n \"author\": {\n \"email\": \"Excepteur id tempor cillum\",\n \"handle\": \"culpa nostrud pariatur\",\n \"name\": \"cillum minim\"\n },\n \"created\": \"1966-02-10T07:56:34.100Z\",\n \"dashboard_count\": 38191328,\n \"id\": 17219875,\n \"is_favorite\": false,\n \"modified\": \"1943-12-25T04:37:37.575Z\",\n \"type\": \"manual_dashboard_list\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard/lists/manual",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard",
"lists",
"manual"
]
}
},
"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}"
}
]
}