Chilkat Online Tools

PowerBuilder / Datadog API Collection / Get an API test

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Operator
integer li_Target
string ls_StrVal
integer li_Day
string ls_From
string ls_V_to
string ls_Name
string ls_Method
string ls_V_Url
integer li_Accept_self_signed
integer li_Allow_insecure
integer li_CheckCertificateRevocation
string ls_ExecutionRule
integer li_DisableCors
integer li_DisableCsp
integer li_Follow_redirects
string ls_HttpVersion
integer li_IgnoreServerCertificateError
integer li_InitialNavigationTimeout
integer li_Min_failure_duration
integer li_Min_location_failed
string ls_Monitor_name
integer li_Renotify_interval
integer li_Monitor_priority
integer li_NoScreenshot
integer li_Count
string ls_Interval
string ls_ApplicationId
integer li_ClientTokenId
integer li_IsEnabled
string ls_Timezone
integer li_Tick_every
string ls_V_type
string ls_Message
integer li_Monitor_id
string ls_Public_id
string ls_Status
string ls_Subtype
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_Http.SetRequestHeader("Accept","application/json")

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

li_Success = loo_Http.QuickGetSb("https://api.app.ddog-gov.com/api/v1/synthetics/tests/api/:public_id",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

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_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

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

// {
//   "name": "Example test name",
//   "config": {
//     "assertions": [
//       {
//         "operator": "lessThan",
//         "target": 1000,
//         "type": "responseTime"
//       }
//     ],
//     "request": {
//       "method": "GET",
//       "url": "https://example.com"
//     }
//   },
//   "locations": [
//     "aws:eu-west-3"
//   ],
//   "options": {
//     "accept_self_signed": true,
//     "allow_insecure": true,
//     "checkCertificateRevocation": true,
//     "ci": {
//       "executionRule": "non_blocking"
//     },
//     "device_ids": [
//       "laptop_large",
//       "laptop_large"
//     ],
//     "disableCors": false,
//     "disableCsp": false,
//     "follow_redirects": true,
//     "httpVersion": "http1",
//     "ignoreServerCertificateError": false,
//     "initialNavigationTimeout": 87780679,
//     "min_failure_duration": -32472759,
//     "min_location_failed": -5806955,
//     "monitor_name": "et deserunt ",
//     "monitor_options": {
//       "renotify_interval": 834
//     },
//     "monitor_priority": 3,
//     "noScreenshot": false,
//     "restricted_roles": [
//       "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
//     ],
//     "retry": {
//       "count": -50657150,
//       "interval": -91565669.0691471
//     },
//     "rumSettings": {
//       "applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
//       "clientTokenId": 12345,
//       "isEnabled": true
//     },
//     "scheduling": {
//       "timeframes": [
//         {
//           "day": 1,
//           "from": "07:00",
//           "to": "16:00"
//         },
//         {
//           "day": 3,
//           "from": "07:00",
//           "to": "16:00"
//         }
//       ],
//       "timezone": "America/New_York"
//     },
//     "tick_every": 384020
//   },
//   "type": "api",
//   "message": "Notification message",
//   "monitor_id": 12345678,
//   "public_id": "123-abc-456",
//   "status": "live",
//   "subtype": "http",
//   "tags": [
//     "env:production"
//   ]
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

ls_Name = loo_JResp.StringOf("name")
ls_Method = loo_JResp.StringOf("config.request.method")
ls_V_Url = loo_JResp.StringOf("config.request.url")
li_Accept_self_signed = loo_JResp.BoolOf("options.accept_self_signed")
li_Allow_insecure = loo_JResp.BoolOf("options.allow_insecure")
li_CheckCertificateRevocation = loo_JResp.BoolOf("options.checkCertificateRevocation")
ls_ExecutionRule = loo_JResp.StringOf("options.ci.executionRule")
li_DisableCors = loo_JResp.BoolOf("options.disableCors")
li_DisableCsp = loo_JResp.BoolOf("options.disableCsp")
li_Follow_redirects = loo_JResp.BoolOf("options.follow_redirects")
ls_HttpVersion = loo_JResp.StringOf("options.httpVersion")
li_IgnoreServerCertificateError = loo_JResp.BoolOf("options.ignoreServerCertificateError")
li_InitialNavigationTimeout = loo_JResp.IntOf("options.initialNavigationTimeout")
li_Min_failure_duration = loo_JResp.IntOf("options.min_failure_duration")
li_Min_location_failed = loo_JResp.IntOf("options.min_location_failed")
ls_Monitor_name = loo_JResp.StringOf("options.monitor_name")
li_Renotify_interval = loo_JResp.IntOf("options.monitor_options.renotify_interval")
li_Monitor_priority = loo_JResp.IntOf("options.monitor_priority")
li_NoScreenshot = loo_JResp.BoolOf("options.noScreenshot")
li_Count = loo_JResp.IntOf("options.retry.count")
ls_Interval = loo_JResp.StringOf("options.retry.interval")
ls_ApplicationId = loo_JResp.StringOf("options.rumSettings.applicationId")
li_ClientTokenId = loo_JResp.IntOf("options.rumSettings.clientTokenId")
li_IsEnabled = loo_JResp.BoolOf("options.rumSettings.isEnabled")
ls_Timezone = loo_JResp.StringOf("options.scheduling.timezone")
li_Tick_every = loo_JResp.IntOf("options.tick_every")
ls_V_type = loo_JResp.StringOf("type")
ls_Message = loo_JResp.StringOf("message")
li_Monitor_id = loo_JResp.IntOf("monitor_id")
ls_Public_id = loo_JResp.StringOf("public_id")
ls_Status = loo_JResp.StringOf("status")
ls_Subtype = loo_JResp.StringOf("subtype")
i = 0
li_Count_i = loo_JResp.SizeOfArray("config.assertions")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Operator = loo_JResp.StringOf("config.assertions[i].operator")
    li_Target = loo_JResp.IntOf("config.assertions[i].target")
    ls_V_type = loo_JResp.StringOf("config.assertions[i].type")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("locations")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("locations[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("options.device_ids")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("options.device_ids[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("options.restricted_roles")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("options.restricted_roles[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("options.scheduling.timeframes")
do while i < li_Count_i
    loo_JResp.I = i
    li_Day = loo_JResp.IntOf("options.scheduling.timeframes[i].day")
    ls_From = loo_JResp.StringOf("options.scheduling.timeframes[i].from")
    ls_V_to = loo_JResp.StringOf("options.scheduling.timeframes[i].to")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("tags")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("tags[i]")
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/synthetics/tests/api/:public_id

Postman Collection Item JSON

{
  "name": "Get an API test",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/synthetics/tests/api/:public_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "synthetics",
        "tests",
        "api",
        ":public_id"
      ],
      "variable": [
        {
          "key": "public_id",
          "value": "tempor Ut sed velit"
        }
      ]
    },
    "description": "Get the detailed configuration associated with\na Synthetic API test."
  },
  "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/synthetics/tests/api/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"name\": \"Example test name\",\n  \"config\": {\n    \"assertions\": [\n      {\n        \"operator\": \"lessThan\",\n        \"target\": 1000,\n        \"type\": \"responseTime\"\n      }\n    ],\n    \"request\": {\n      \"method\": \"GET\",\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"locations\": [\n    \"aws:eu-west-3\"\n  ],\n  \"options\": {\n    \"accept_self_signed\": true,\n    \"allow_insecure\": true,\n    \"checkCertificateRevocation\": true,\n    \"ci\": {\n      \"executionRule\": \"non_blocking\"\n    },\n    \"device_ids\": [\n      \"laptop_large\",\n      \"laptop_large\"\n    ],\n    \"disableCors\": false,\n    \"disableCsp\": false,\n    \"follow_redirects\": true,\n    \"httpVersion\": \"http1\",\n    \"ignoreServerCertificateError\": false,\n    \"initialNavigationTimeout\": 87780679,\n    \"min_failure_duration\": -32472759,\n    \"min_location_failed\": -5806955,\n    \"monitor_name\": \"et deserunt \",\n    \"monitor_options\": {\n      \"renotify_interval\": 834\n    },\n    \"monitor_priority\": 3,\n    \"noScreenshot\": false,\n    \"restricted_roles\": [\n      \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\n    ],\n    \"retry\": {\n      \"count\": -50657150,\n      \"interval\": -91565669.0691471\n    },\n    \"rumSettings\": {\n      \"applicationId\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n      \"clientTokenId\": 12345,\n      \"isEnabled\": true\n    },\n    \"scheduling\": {\n      \"timeframes\": [\n        {\n          \"day\": 1,\n          \"from\": \"07:00\",\n          \"to\": \"16:00\"\n        },\n        {\n          \"day\": 3,\n          \"from\": \"07:00\",\n          \"to\": \"16:00\"\n        }\n      ],\n      \"timezone\": \"America/New_York\"\n    },\n    \"tick_every\": 384020\n  },\n  \"type\": \"api\",\n  \"message\": \"Notification message\",\n  \"monitor_id\": 12345678,\n  \"public_id\": \"123-abc-456\",\n  \"status\": \"live\",\n  \"subtype\": \"http\",\n  \"tags\": [\n    \"env:production\"\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/v1/synthetics/tests/api/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_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": "- Synthetic Monitoring is not activated for the user\n- Test is not owned by the user",
      "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/synthetics/tests/api/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_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/synthetics/tests/api/:public_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            "api",
            ":public_id"
          ],
          "variable": [
            {
              "key": "public_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}"
    }
  ]
}