Chilkat Online Tools

PowerBuilder / Datadog API Collection / Get all dashboards

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Author_handle
string ls_Created_at
string ls_Description
string ls_Id
integer li_Is_read_only
string ls_Layout_type
string ls_Modified_at
string ls_Title
string ls_Url
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("filter[shared]","false")
loo_QueryParams.UpdateString("filter[deleted]","false")

loo_Http.SetRequestHeader("Accept","application/json")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api.app.ddog-gov.com/api/v1/dashboard",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_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

i = 0
li_Count_i = loo_JResp.SizeOfArray("dashboards")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Author_handle = loo_JResp.StringOf("dashboards[i].author_handle")
    ls_Created_at = loo_JResp.StringOf("dashboards[i].created_at")
    ls_Description = loo_JResp.StringOf("dashboards[i].description")
    ls_Id = loo_JResp.StringOf("dashboards[i].id")
    li_Is_read_only = loo_JResp.BoolOf("dashboards[i].is_read_only")
    ls_Layout_type = loo_JResp.StringOf("dashboards[i].layout_type")
    ls_Modified_at = loo_JResp.StringOf("dashboards[i].modified_at")
    ls_Title = loo_JResp.StringOf("dashboards[i].title")
    ls_Url = loo_JResp.StringOf("dashboards[i].url")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_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}"
    }
  ]
}