Chilkat Online Tools

DataFlex / Datadog API Collection / Get API key

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vQueryParams
    Handle hoQueryParams
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sAttributesCreated_at
    String sDisabled
    String sV_Email
    String sHandle
    String sIcon
    String sAttributesModified_at
    String sAttributesName
    String sService_account
    String sStatus
    String sTitle
    String sVerified
    String sId
    String sV_type
    Integer j
    Integer iCount_j
    String sCreated_at
    String sKey
    String sLast4
    String sModified_at
    String sName
    String sId
    String sDataId
    String sV_Type
    String sDataType
    String sDataType
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
    If (Not(IsComObjectCreated(hoQueryParams))) Begin
        Send CreateComObject of hoQueryParams
    End
    Get ComUpdateString Of hoQueryParams "include" "<string>" To iSuccess

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

    Get pvComObject of hoQueryParams to vQueryParams
    Get ComQuickRequestParams Of hoHttp "GET" "https://api.app.ddog-gov.com/api/v2/api_keys/:api_key_id" vQueryParams To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    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 ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "data": {
    //     "attributes": {
    //       "created_at": "<string>",
    //       "key": "<string>",
    //       "last4": "<string>",
    //       "modified_at": "<string>",
    //       "name": "<string>"
    //     },
    //     "id": "<string>",
    //     "relationships": {
    //       "created_by": {
    //         "data": {
    //           "id": "<string>",
    //           "type": "users"
    //         }
    //       },
    //       "modified_by": {
    //         "data": {
    //           "id": "<string>",
    //           "type": "users"
    //         }
    //       }
    //     },
    //     "type": "api_keys"
    //   },
    //   "included": [
    //     {
    //       "attributes": {
    //         "created_at": "<dateTime>",
    //         "disabled": "<boolean>",
    //         "email": "<string>",
    //         "handle": "<string>",
    //         "icon": "<string>",
    //         "modified_at": "<dateTime>",
    //         "name": "<string>",
    //         "service_account": "<boolean>",
    //         "status": "<string>",
    //         "title": "<string>",
    //         "verified": "<boolean>"
    //       },
    //       "id": "<string>",
    //       "relationships": {
    //         "org": {
    //           "data": {
    //             "id": "<string>",
    //             "type": "orgs"
    //           }
    //         },
    //         "other_orgs": {
    //           "data": [
    //             {
    //               "id": "<string>",
    //               "type": "orgs"
    //             },
    //             {
    //               "id": "<string>",
    //               "type": "orgs"
    //             }
    //           ]
    //         },
    //         "other_users": {
    //           "data": [
    //             {
    //               "id": "<string>",
    //               "type": "users"
    //             },
    //             {
    //               "id": "<string>",
    //               "type": "users"
    //             }
    //           ]
    //         },
    //         "roles": {
    //           "data": [
    //             {
    //               "id": "<string>",
    //               "type": "roles"
    //             },
    //             {
    //               "id": "<string>",
    //               "type": "roles"
    //             }
    //           ]
    //         }
    //       },
    //       "type": "users"
    //     },
    //     {
    //       "attributes": {
    //         "created_at": "<dateTime>",
    //         "disabled": "<boolean>",
    //         "email": "<string>",
    //         "handle": "<string>",
    //         "icon": "<string>",
    //         "modified_at": "<dateTime>",
    //         "name": "<string>",
    //         "service_account": "<boolean>",
    //         "status": "<string>",
    //         "title": "<string>",
    //         "verified": "<boolean>"
    //       },
    //       "id": "<string>",
    //       "relationships": {
    //         "org": {
    //           "data": {
    //             "id": "<string>",
    //             "type": "orgs"
    //           }
    //         },
    //         "other_orgs": {
    //           "data": [
    //             {
    //               "id": "<string>",
    //               "type": "orgs"
    //             },
    //             {
    //               "id": "<string>",
    //               "type": "orgs"
    //             }
    //           ]
    //         },
    //         "other_users": {
    //           "data": [
    //             {
    //               "id": "<string>",
    //               "type": "users"
    //             },
    //             {
    //               "id": "<string>",
    //               "type": "users"
    //             }
    //           ]
    //         },
    //         "roles": {
    //           "data": [
    //             {
    //               "id": "<string>",
    //               "type": "roles"
    //             },
    //             {
    //               "id": "<string>",
    //               "type": "roles"
    //             }
    //           ]
    //         }
    //       },
    //       "type": "users"
    //     }
    //   ]
    // }

    // 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 "data.attributes.created_at" To sCreated_at
    Get ComStringOf Of hoJResp "data.attributes.key" To sKey
    Get ComStringOf Of hoJResp "data.attributes.last4" To sLast4
    Get ComStringOf Of hoJResp "data.attributes.modified_at" To sModified_at
    Get ComStringOf Of hoJResp "data.attributes.name" To sName
    Get ComStringOf Of hoJResp "data.id" To sId
    Get ComStringOf Of hoJResp "data.relationships.created_by.data.id" To sDataId
    Get ComStringOf Of hoJResp "data.relationships.created_by.data.type" To sV_Type
    Get ComStringOf Of hoJResp "data.relationships.modified_by.data.id" To sDataId
    Get ComStringOf Of hoJResp "data.relationships.modified_by.data.type" To sDataType
    Get ComStringOf Of hoJResp "data.type" To sDataType
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "included" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "included[i].attributes.created_at" To sAttributesCreated_at
        Get ComStringOf Of hoJResp "included[i].attributes.disabled" To sDisabled
        Get ComStringOf Of hoJResp "included[i].attributes.email" To sV_Email
        Get ComStringOf Of hoJResp "included[i].attributes.handle" To sHandle
        Get ComStringOf Of hoJResp "included[i].attributes.icon" To sIcon
        Get ComStringOf Of hoJResp "included[i].attributes.modified_at" To sAttributesModified_at
        Get ComStringOf Of hoJResp "included[i].attributes.name" To sAttributesName
        Get ComStringOf Of hoJResp "included[i].attributes.service_account" To sService_account
        Get ComStringOf Of hoJResp "included[i].attributes.status" To sStatus
        Get ComStringOf Of hoJResp "included[i].attributes.title" To sTitle
        Get ComStringOf Of hoJResp "included[i].attributes.verified" To sVerified
        Get ComStringOf Of hoJResp "included[i].id" To sId
        Get ComStringOf Of hoJResp "included[i].relationships.org.data.id" To sDataId
        Get ComStringOf Of hoJResp "included[i].relationships.org.data.type" To sDataType
        Get ComStringOf Of hoJResp "included[i].type" To sV_type
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "included[i].relationships.other_orgs.data" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "included[i].relationships.other_orgs.data[j].id" To sId
            Get ComStringOf Of hoJResp "included[i].relationships.other_orgs.data[j].type" To sV_type
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "included[i].relationships.other_users.data" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "included[i].relationships.other_users.data[j].id" To sId
            Get ComStringOf Of hoJResp "included[i].relationships.other_users.data[j].type" To sV_type
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "included[i].relationships.roles.data" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "included[i].relationships.roles.data[j].id" To sId
            Get ComStringOf Of hoJResp "included[i].relationships.roles.data[j].type" To sV_type
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -G -d "include=%3Cstring%3E"
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/api_keys/:api_key_id

Postman Collection Item JSON

{
  "name": "Get API key",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/api_keys/:api_key_id?include=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "api_keys",
        ":api_key_id"
      ],
      "query": [
        {
          "key": "include",
          "value": "<string>",
          "description": "Comma separated list of resource paths for related resources to include in the response. Supported resource paths are `created_by` and `modified_by`."
        }
      ],
      "variable": [
        {
          "key": "api_key_id",
          "value": "<string>"
        }
      ]
    },
    "description": "Get an API key."
  },
  "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/v2/api_keys/:api_key_id?include=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "api_keys",
            ":api_key_id"
          ],
          "query": [
            {
              "key": "include",
              "value": "<string>",
              "description": "Comma separated list of resource paths for related resources to include in the response. Supported resource paths are `created_by` and `modified_by`."
            }
          ],
          "variable": [
            {
              "key": "api_key_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"attributes\": {\n      \"created_at\": \"<string>\",\n      \"key\": \"<string>\",\n      \"last4\": \"<string>\",\n      \"modified_at\": \"<string>\",\n      \"name\": \"<string>\"\n    },\n    \"id\": \"<string>\",\n    \"relationships\": {\n      \"created_by\": {\n        \"data\": {\n          \"id\": \"<string>\",\n          \"type\": \"users\"\n        }\n      },\n      \"modified_by\": {\n        \"data\": {\n          \"id\": \"<string>\",\n          \"type\": \"users\"\n        }\n      }\n    },\n    \"type\": \"api_keys\"\n  },\n  \"included\": [\n    {\n      \"attributes\": {\n        \"created_at\": \"<dateTime>\",\n        \"disabled\": \"<boolean>\",\n        \"email\": \"<string>\",\n        \"handle\": \"<string>\",\n        \"icon\": \"<string>\",\n        \"modified_at\": \"<dateTime>\",\n        \"name\": \"<string>\",\n        \"service_account\": \"<boolean>\",\n        \"status\": \"<string>\",\n        \"title\": \"<string>\",\n        \"verified\": \"<boolean>\"\n      },\n      \"id\": \"<string>\",\n      \"relationships\": {\n        \"org\": {\n          \"data\": {\n            \"id\": \"<string>\",\n            \"type\": \"orgs\"\n          }\n        },\n        \"other_orgs\": {\n          \"data\": [\n            {\n              \"id\": \"<string>\",\n              \"type\": \"orgs\"\n            },\n            {\n              \"id\": \"<string>\",\n              \"type\": \"orgs\"\n            }\n          ]\n        },\n        \"other_users\": {\n          \"data\": [\n            {\n              \"id\": \"<string>\",\n              \"type\": \"users\"\n            },\n            {\n              \"id\": \"<string>\",\n              \"type\": \"users\"\n            }\n          ]\n        },\n        \"roles\": {\n          \"data\": [\n            {\n              \"id\": \"<string>\",\n              \"type\": \"roles\"\n            },\n            {\n              \"id\": \"<string>\",\n              \"type\": \"roles\"\n            }\n          ]\n        }\n      },\n      \"type\": \"users\"\n    },\n    {\n      \"attributes\": {\n        \"created_at\": \"<dateTime>\",\n        \"disabled\": \"<boolean>\",\n        \"email\": \"<string>\",\n        \"handle\": \"<string>\",\n        \"icon\": \"<string>\",\n        \"modified_at\": \"<dateTime>\",\n        \"name\": \"<string>\",\n        \"service_account\": \"<boolean>\",\n        \"status\": \"<string>\",\n        \"title\": \"<string>\",\n        \"verified\": \"<boolean>\"\n      },\n      \"id\": \"<string>\",\n      \"relationships\": {\n        \"org\": {\n          \"data\": {\n            \"id\": \"<string>\",\n            \"type\": \"orgs\"\n          }\n        },\n        \"other_orgs\": {\n          \"data\": [\n            {\n              \"id\": \"<string>\",\n              \"type\": \"orgs\"\n            },\n            {\n              \"id\": \"<string>\",\n              \"type\": \"orgs\"\n            }\n          ]\n        },\n        \"other_users\": {\n          \"data\": [\n            {\n              \"id\": \"<string>\",\n              \"type\": \"users\"\n            },\n            {\n              \"id\": \"<string>\",\n              \"type\": \"users\"\n            }\n          ]\n        },\n        \"roles\": {\n          \"data\": [\n            {\n              \"id\": \"<string>\",\n              \"type\": \"roles\"\n            },\n            {\n              \"id\": \"<string>\",\n              \"type\": \"roles\"\n            }\n          ]\n        }\n      },\n      \"type\": \"users\"\n    }\n  ]\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/v2/api_keys/:api_key_id?include=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "api_keys",
            ":api_key_id"
          ],
          "query": [
            {
              "key": "include",
              "value": "<string>",
              "description": "Comma separated list of resource paths for related resources to include in the response. Supported resource paths are `created_by` and `modified_by`."
            }
          ],
          "variable": [
            {
              "key": "api_key_id"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\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/v2/api_keys/:api_key_id?include=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "api_keys",
            ":api_key_id"
          ],
          "query": [
            {
              "key": "include",
              "value": "<string>",
              "description": "Comma separated list of resource paths for related resources to include in the response. Supported resource paths are `created_by` and `modified_by`."
            }
          ],
          "variable": [
            {
              "key": "api_key_id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\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/v2/api_keys/:api_key_id?include=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "api_keys",
            ":api_key_id"
          ],
          "query": [
            {
              "key": "include",
              "value": "<string>",
              "description": "Comma separated list of resource paths for related resources to include in the response. Supported resource paths are `created_by` and `modified_by`."
            }
          ],
          "variable": [
            {
              "key": "api_key_id"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    }
  ]
}