Chilkat Online Tools

DataFlex / Datadog API Collection / Get a dashboard list

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sName
    String sV_Email
    String sHandle
    String sName
    String sCreated
    Integer iDashboard_count
    Integer iId
    Boolean iIs_favorite
    String sModified
    String sV_type
    String sTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://api.app.ddog-gov.com/api/v1/dashboard/lists/manual/:list_id" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // 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

    Get ComStringOf Of hoJResp "name" To sName
    Get ComStringOf Of hoJResp "author.email" To sV_Email
    Get ComStringOf Of hoJResp "author.handle" To sHandle
    Get ComStringOf Of hoJResp "author.name" To sName
    Get ComStringOf Of hoJResp "created" To sCreated
    Get ComIntOf Of hoJResp "dashboard_count" To iDashboard_count
    Get ComIntOf Of hoJResp "id" To iId
    Get ComBoolOf Of hoJResp "is_favorite" To iIs_favorite
    Get ComStringOf Of hoJResp "modified" To sModified
    Get ComStringOf Of hoJResp "type" To sV_type


End_Procedure

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/dashboard/lists/manual/:list_id

Postman Collection Item JSON

{
  "name": "Get a dashboard list",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/dashboard/lists/manual/:list_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "dashboard",
        "lists",
        "manual",
        ":list_id"
      ],
      "variable": [
        {
          "key": "list_id",
          "value": "-62147425"
        }
      ]
    },
    "description": "Fetch an existing dashboard list's definition."
  },
  "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/lists/manual/:list_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "lists",
            "manual",
            ":list_id"
          ],
          "variable": [
            {
              "key": "list_id"
            }
          ]
        }
      },
      "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": "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/lists/manual/:list_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "lists",
            "manual",
            ":list_id"
          ],
          "variable": [
            {
              "key": "list_id"
            }
          ]
        }
      },
      "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": "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/lists/manual/:list_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "lists",
            "manual",
            ":list_id"
          ],
          "variable": [
            {
              "key": "list_id"
            }
          ]
        }
      },
      "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/lists/manual/:list_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "lists",
            "manual",
            ":list_id"
          ],
          "variable": [
            {
              "key": "list_id"
            }
          ]
        }
      },
      "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}"
    }
  ]
}