Chilkat Online Tools

DataFlex / Datadog API Collection / Get a shared dashboard

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 sDefault_value
    String sName
    String sPrefix
    Integer j
    Integer iCount_j
    String sStrVal
    String sDashboard_id
    String sDashboard_type
    String sHandle
    String sName
    String sCreated_at
    String sLive_span
    Boolean iGlobal_time_selectable_enabled
    String sPublic_url
    String sShare_type
    String sToken
    Integer i
    Integer iCount_i
    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/public/:token" 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)

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

    Get ComStringOf Of hoJResp "dashboard_id" To sDashboard_id
    Get ComStringOf Of hoJResp "dashboard_type" To sDashboard_type
    Get ComStringOf Of hoJResp "author.handle" To sHandle
    Get ComStringOf Of hoJResp "author.name" To sName
    Get ComStringOf Of hoJResp "created_at" To sCreated_at
    Get ComStringOf Of hoJResp "global_time.live_span" To sLive_span
    Get ComBoolOf Of hoJResp "global_time_selectable_enabled" To iGlobal_time_selectable_enabled
    Get ComStringOf Of hoJResp "public_url" To sPublic_url
    Get ComStringOf Of hoJResp "share_type" To sShare_type
    Get ComStringOf Of hoJResp "token" To sToken
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "selectable_template_vars" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "selectable_template_vars[i].default_value" To sDefault_value
        Get ComStringOf Of hoJResp "selectable_template_vars[i].name" To sName
        Get ComStringOf Of hoJResp "selectable_template_vars[i].prefix" To sPrefix
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "selectable_template_vars[i].visible_tags" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "selectable_template_vars[i].visible_tags[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "share_list" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "share_list[i]" To sStrVal
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

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

Postman Collection Item JSON

{
  "name": "Get a shared dashboard",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/dashboard/public/:token",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "dashboard",
        "public",
        ":token"
      ],
      "variable": [
        {
          "key": "token",
          "value": "tempor Ut sed velit"
        }
      ]
    },
    "description": "Fetch an existing shared dashboard's sharing metadata associated with the specified token."
  },
  "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/public/:token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "public",
            ":token"
          ],
          "variable": [
            {
              "key": "token"
            }
          ]
        }
      },
      "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": "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/public/:token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "public",
            ":token"
          ],
          "variable": [
            {
              "key": "token"
            }
          ]
        }
      },
      "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": "Shared Dashboard 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/public/:token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "public",
            ":token"
          ],
          "variable": [
            {
              "key": "token"
            }
          ]
        }
      },
      "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/public/:token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            "public",
            ":token"
          ],
          "variable": [
            {
              "key": "token"
            }
          ]
        }
      },
      "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}"
    }
  ]
}