Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW queryParams;
HCkHttpResponseW resp;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *author_handle;
const wchar_t *created_at;
const wchar_t *description;
const wchar_t *id;
BOOL is_read_only;
const wchar_t *layout_type;
const wchar_t *modified_at;
const wchar_t *title;
const wchar_t *url;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
queryParams = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(queryParams,L"filter[shared]",L"false");
CkJsonObjectW_UpdateString(queryParams,L"filter[deleted]",L"false");
CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://api.app.ddog-gov.com/api/v1/dashboard",queryParams);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
return;
}
sbResponseBody = CkStringBuilderW_Create();
CkHttpResponseW_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Failed.\n");
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
CkHttpResponseW_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "dashboards": [
// {
// "author_handle": "Duis tempor ex",
// "created_at": "1963-12-20T01:10:02.870Z",
// "description": "esse cillum laboris",
// "id": "do Ut",
// "is_read_only": true,
// "layout_type": "ordered",
// "modified_at": "1958-09-05T14:28:29.291Z",
// "title": "nulla velit tempor",
// "url": "quis laboris irure id"
// },
// {
// "author_handle": "cup",
// "created_at": "1992-05-21T18:14:01.464Z",
// "description": "proident incididunt dolore",
// "id": "in deserunt irure",
// "is_read_only": false,
// "layout_type": "ordered",
// "modified_at": "1971-12-02T02:50:20.074Z",
// "title": "ut dolor in consequat fugiat",
// "url": "culpa Duis mollit"
// }
// ]
// }
// 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.
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"dashboards");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
author_handle = CkJsonObjectW_stringOf(jResp,L"dashboards[i].author_handle");
created_at = CkJsonObjectW_stringOf(jResp,L"dashboards[i].created_at");
description = CkJsonObjectW_stringOf(jResp,L"dashboards[i].description");
id = CkJsonObjectW_stringOf(jResp,L"dashboards[i].id");
is_read_only = CkJsonObjectW_BoolOf(jResp,L"dashboards[i].is_read_only");
layout_type = CkJsonObjectW_stringOf(jResp,L"dashboards[i].layout_type");
modified_at = CkJsonObjectW_stringOf(jResp,L"dashboards[i].modified_at");
title = CkJsonObjectW_stringOf(jResp,L"dashboards[i].title");
url = CkJsonObjectW_stringOf(jResp,L"dashboards[i].url");
i = i + 1;
}
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -G -d "filter[shared]=false"
-d "filter[deleted]=false"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/dashboard
Postman Collection Item JSON
{
"name": "Get all dashboards",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/dashboard?filter[shared]=false&filter[deleted]=false",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard"
],
"query": [
{
"key": "filter[shared]",
"value": "false",
"description": "When `true`, this query only returns shared custom created\nor cloned dashboards."
},
{
"key": "filter[deleted]",
"value": "false",
"description": "When `true`, this query returns only deleted custom-created\nor cloned dashboards. This parameter is incompatible with `filter[shared]`."
}
]
},
"description": "Get all dashboards.\n\n**Note**: This query will only return custom created or cloned dashboards.\nThis query will not return preset dashboards."
},
"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?filter[shared]=false&filter[deleted]=false",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard"
],
"query": [
{
"key": "filter[shared]",
"value": "false",
"description": "When `true`, this query only returns shared custom created\nor cloned dashboards."
},
{
"key": "filter[deleted]",
"value": "false",
"description": "When `true`, this query returns only deleted custom-created\nor cloned dashboards. This parameter is incompatible with `filter[shared]`."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"dashboards\": [\n {\n \"author_handle\": \"Duis tempor ex\",\n \"created_at\": \"1963-12-20T01:10:02.870Z\",\n \"description\": \"esse cillum laboris\",\n \"id\": \"do Ut\",\n \"is_read_only\": true,\n \"layout_type\": \"ordered\",\n \"modified_at\": \"1958-09-05T14:28:29.291Z\",\n \"title\": \"nulla velit tempor\",\n \"url\": \"quis laboris irure id\"\n },\n {\n \"author_handle\": \"cup\",\n \"created_at\": \"1992-05-21T18:14:01.464Z\",\n \"description\": \"proident incididunt dolore\",\n \"id\": \"in deserunt irure\",\n \"is_read_only\": false,\n \"layout_type\": \"ordered\",\n \"modified_at\": \"1971-12-02T02:50:20.074Z\",\n \"title\": \"ut dolor in consequat fugiat\",\n \"url\": \"culpa Duis mollit\"\n }\n ]\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?filter[shared]=false&filter[deleted]=false",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard"
],
"query": [
{
"key": "filter[shared]",
"value": "false",
"description": "When `true`, this query only returns shared custom created\nor cloned dashboards."
},
{
"key": "filter[deleted]",
"value": "false",
"description": "When `true`, this query returns only deleted custom-created\nor cloned dashboards. This parameter is incompatible with `filter[shared]`."
}
]
}
},
"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": "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?filter[shared]=false&filter[deleted]=false",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"dashboard"
],
"query": [
{
"key": "filter[shared]",
"value": "false",
"description": "When `true`, this query only returns shared custom created\nor cloned dashboards."
},
{
"key": "filter[deleted]",
"value": "false",
"description": "When `true`, this query returns only deleted custom-created\nor cloned dashboards. This parameter is incompatible with `filter[shared]`."
}
]
}
},
"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}"
}
]
}