Chilkat Online Tools

autoit / Datadog API Collection / Get an API test result

Back to Collection Items

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

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oHttp.SetRequestHeader "Accept","application/json"

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://api.app.ddog-gov.com/api/v1/synthetics/tests/:public_id/results/:result_id",$oSbResponseBody)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oHttp.LastHeader & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

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

; {
;   "check": {
;     "config": {
;       "configVariables": [
;         {
;           "description": "Example for the variable.",
;           "type": "string"
;         },
;         {
;           "description": "Example for the variable.",
;           "type": "string"
;         }
;       ],
;       "request": {
;         "allow_insecure": false,
;         "basicAuth": {
;           "password": "PaSSw0RD!",
;           "username": "my_username",
;           "type": "web"
;         },
;         "body": "proident",
;         "bodyType": "text/plain",
;         "callType": "unary",
;         "certificate": {
;           "cert": {
;             "content": "reprehenderit labore Ut sed mollit",
;             "filename": "Duis consectetur incididunt eiusmod",
;             "updatedAt": "aliquip in"
;           },
;           "key": {
;             "content": "consequat sint nulla aute aliquip",
;             "filename": "non nisi",
;             "updatedAt": "et"
;           }
;         },
;         "compressedJsonDescriptor": "dolore",
;         "dnsServer": "elit nostrud in adipisic",
;         "dnsServerPort": 60578,
;         "follow_redirects": false,
;         "headers": {
;           "proident_69": "quis dolor occaecat"
;         },
;         "host": "laborum laboris",
;         "message": "aliqua ea laborum laboris",
;         "metadata": {
;           "dolor_d": "veniam nostrud anim nulla",
;           "labore_7c6": "consequat eu",
;           "sed002": "Excepteur eiusmod adipisicing"
;         },
;         "method": "et irure",
;         "noSavingResponseBody": false,
;         "numberOfPackets": 9,
;         "persistCookies": false,
;         "port": 99104800,
;         "proxy": {
;           "url": "https://example.com",
;           "headers": {
;             "ead": "i"
;           }
;         },
;         "query": {},
;         "servername": "cillum enim adipisicing",
;         "service": "Greeter",
;         "shouldTrackHops": true,
;         "timeout": -43666416.92792323,
;         "url": "https://example.com"
;       },
;       "variables": [
;         {
;           "description": "Example for the variable.",
;           "type": "string"
;         },
;         {
;           "description": "Example for the variable.",
;           "type": "string"
;         }
;       ]
;     }
;   },
;   "check_time": -61984290.348021574,
;   "check_version": -35585398,
;   "probe_dc": "Duis aute",
;   "result": {
;     "cert": {
;       "cipher": "laborum dolore elit reprehenderit",
;       "exponent": -97057115.16341409,
;       "extKeyUsage": [
;         "e",
;         "non nulla"
;       ],
;       "fingerprint": "enim",
;       "fingerprint256": "commodo Duis elit culpa",
;       "issuer": {
;         "C": "id",
;         "CN": "dolor esse",
;         "L": "Lorem magna",
;         "O": "adipisicing ullamco",
;         "OU": "nostrud labore",
;         "ST": "proident consequat ut"
;       },
;       "modulus": "ut dolore cupidatat officia",
;       "protocol": "cillum dolor commodo sit",
;       "serialNumber": "velit",
;       "subject": {
;         "C": "aliquip ad voluptate",
;         "CN": "irure",
;         "L": "elit",
;         "O": "in",
;         "OU": "cillum dolor dolor aliquip nulla",
;         "ST": "mollit velit et",
;         "altName": "veniam eu mollit irure"
;       },
;       "validFrom": "1993-10-19T21:25:09.532Z",
;       "validTo": "2015-01-05T06:21:16.689Z"
;     },
;     "eventType": "finished_with_error",
;     "failure": {
;       "code": "DECRYPTION",
;       "message": "Error during DNS resolution (ENOTFOUND)."
;     },
;     "httpStatusCode": 81890255,
;     "requestHeaders": {
;       "Ut2": {},
;       "ad_29": {}
;     },
;     "responseBody": "Excepteur laboris Ut dolor",
;     "responseHeaders": {
;       "ut19b": {
;         "description": "Returned request header."
;       },
;       "Ut_270": {
;         "description": "Returned request header."
;       }
;     },
;     "responseSize": -51226186,
;     "timings": {
;       "dns": 31944439.48881416,
;       "download": -87539924.41719314,
;       "firstByte": -96589047.25818287,
;       "handshake": 84645232.54590705,
;       "redirect": -32741896.0310553,
;       "ssl": -93300794.33204812,
;       "tcp": 65643.03422442079,
;       "total": 82914630.9958055,
;       "wait": 29723058.510239527
;     }
;   },
;   "result_id": "culpa adipisicing consectetur sit",
;   "status": 1
; }

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

Local $sDescription
Local $sV_type
Local $strVal

Local $bAllow_insecure = $oJResp.BoolOf("check.config.request.allow_insecure")
Local $sPassword = $oJResp.StringOf("check.config.request.basicAuth.password")
Local $sUsername = $oJResp.StringOf("check.config.request.basicAuth.username")
Local $sV_Type = $oJResp.StringOf("check.config.request.basicAuth.type")
Local $sBody = $oJResp.StringOf("check.config.request.body")
Local $sBodyType = $oJResp.StringOf("check.config.request.bodyType")
Local $sCallType = $oJResp.StringOf("check.config.request.callType")
Local $sContent = $oJResp.StringOf("check.config.request.certificate.cert.content")
Local $sFilename = $oJResp.StringOf("check.config.request.certificate.cert.filename")
Local $sUpdatedAt = $oJResp.StringOf("check.config.request.certificate.cert.updatedAt")
Local $sKeyContent = $oJResp.StringOf("check.config.request.certificate.key.content")
Local $sKeyFilename = $oJResp.StringOf("check.config.request.certificate.key.filename")
Local $sKeyUpdatedAt = $oJResp.StringOf("check.config.request.certificate.key.updatedAt")
Local $sCompressedJsonDescriptor = $oJResp.StringOf("check.config.request.compressedJsonDescriptor")
Local $sDnsServer = $oJResp.StringOf("check.config.request.dnsServer")
Local $iDnsServerPort = $oJResp.IntOf("check.config.request.dnsServerPort")
Local $bFollow_redirects = $oJResp.BoolOf("check.config.request.follow_redirects")
Local $sProident_69 = $oJResp.StringOf("check.config.request.headers.proident_69")
Local $sHost = $oJResp.StringOf("check.config.request.host")
Local $sMessage = $oJResp.StringOf("check.config.request.message")
Local $sDolor_d = $oJResp.StringOf("check.config.request.metadata.dolor_d")
Local $sLabore_7c6 = $oJResp.StringOf("check.config.request.metadata.labore_7c6")
Local $sSed002 = $oJResp.StringOf("check.config.request.metadata.sed002")
Local $sMethod = $oJResp.StringOf("check.config.request.method")
Local $bNoSavingResponseBody = $oJResp.BoolOf("check.config.request.noSavingResponseBody")
Local $iNumberOfPackets = $oJResp.IntOf("check.config.request.numberOfPackets")
Local $bPersistCookies = $oJResp.BoolOf("check.config.request.persistCookies")
Local $iPort = $oJResp.IntOf("check.config.request.port")
Local $sV_Url = $oJResp.StringOf("check.config.request.proxy.url")
Local $sEad = $oJResp.StringOf("check.config.request.proxy.headers.ead")
Local $sServername = $oJResp.StringOf("check.config.request.servername")
Local $sService = $oJResp.StringOf("check.config.request.service")
Local $bShouldTrackHops = $oJResp.BoolOf("check.config.request.shouldTrackHops")
Local $sTimeout = $oJResp.StringOf("check.config.request.timeout")
Local $sRequestUrl = $oJResp.StringOf("check.config.request.url")
Local $sCheck_time = $oJResp.StringOf("check_time")
Local $iCheck_version = $oJResp.IntOf("check_version")
Local $sProbe_dc = $oJResp.StringOf("probe_dc")
Local $sCipher = $oJResp.StringOf("result.cert.cipher")
Local $sExponent = $oJResp.StringOf("result.cert.exponent")
Local $sFingerprint = $oJResp.StringOf("result.cert.fingerprint")
Local $sFingerprint256 = $oJResp.StringOf("result.cert.fingerprint256")
Local $sC = $oJResp.StringOf("result.cert.issuer.C")
Local $sCN = $oJResp.StringOf("result.cert.issuer.CN")
Local $sL = $oJResp.StringOf("result.cert.issuer.L")
Local $sO = $oJResp.StringOf("result.cert.issuer.O")
Local $sOU = $oJResp.StringOf("result.cert.issuer.OU")
Local $sST = $oJResp.StringOf("result.cert.issuer.ST")
Local $sModulus = $oJResp.StringOf("result.cert.modulus")
Local $sProtocol = $oJResp.StringOf("result.cert.protocol")
Local $sSerialNumber = $oJResp.StringOf("result.cert.serialNumber")
Local $sSubjectC = $oJResp.StringOf("result.cert.subject.C")
Local $sSubjectCN = $oJResp.StringOf("result.cert.subject.CN")
Local $sSubjectL = $oJResp.StringOf("result.cert.subject.L")
Local $sSubjectO = $oJResp.StringOf("result.cert.subject.O")
Local $sSubjectOU = $oJResp.StringOf("result.cert.subject.OU")
Local $sSubjectST = $oJResp.StringOf("result.cert.subject.ST")
Local $sAltName = $oJResp.StringOf("result.cert.subject.altName")
Local $sValidFrom = $oJResp.StringOf("result.cert.validFrom")
Local $sValidTo = $oJResp.StringOf("result.cert.validTo")
Local $sEventType = $oJResp.StringOf("result.eventType")
Local $sCode = $oJResp.StringOf("result.failure.code")
Local $sFailureMessage = $oJResp.StringOf("result.failure.message")
Local $iHttpStatusCode = $oJResp.IntOf("result.httpStatusCode")
Local $sResponseBody = $oJResp.StringOf("result.responseBody")
Local $sDescription = $oJResp.StringOf("result.responseHeaders.ut19b.description")
Local $sUt_270Description = $oJResp.StringOf("result.responseHeaders.Ut_270.description")
Local $iResponseSize = $oJResp.IntOf("result.responseSize")
Local $sV_Dns = $oJResp.StringOf("result.timings.dns")
Local $sDownload = $oJResp.StringOf("result.timings.download")
Local $sFirstByte = $oJResp.StringOf("result.timings.firstByte")
Local $sHandshake = $oJResp.StringOf("result.timings.handshake")
Local $sRedirect = $oJResp.StringOf("result.timings.redirect")
Local $sSsl = $oJResp.StringOf("result.timings.ssl")
Local $sTcp = $oJResp.StringOf("result.timings.tcp")
Local $sTotal = $oJResp.StringOf("result.timings.total")
Local $sWait = $oJResp.StringOf("result.timings.wait")
Local $sResult_id = $oJResp.StringOf("result_id")
Local $iStatus = $oJResp.IntOf("status")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("check.config.configVariables")
While $i < $iCount_i
    $oJResp.I = $i
    $sDescription = $oJResp.StringOf("check.config.configVariables[i].description")
    $sV_type = $oJResp.StringOf("check.config.configVariables[i].type")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("check.config.variables")
While $i < $iCount_i
    $oJResp.I = $i
    $sDescription = $oJResp.StringOf("check.config.variables[i].description")
    $sV_type = $oJResp.StringOf("check.config.variables[i].type")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("result.cert.extKeyUsage")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("result.cert.extKeyUsage[i]")
    $i = $i + 1
Wend

Curl Command

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

Postman Collection Item JSON

{
  "name": "Get an API test result",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/synthetics/tests/:public_id/results/:result_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "synthetics",
        "tests",
        ":public_id",
        "results",
        ":result_id"
      ],
      "variable": [
        {
          "key": "public_id",
          "value": "tempor Ut sed velit"
        },
        {
          "key": "result_id",
          "value": "tempor Ut sed velit"
        }
      ]
    },
    "description": "Get a specific full result from a given 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/:public_id/results/:result_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            ":public_id",
            "results",
            ":result_id"
          ],
          "variable": [
            {
              "key": "public_id"
            },
            {
              "key": "result_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"check\": {\n    \"config\": {\n      \"configVariables\": [\n        {\n          \"description\": \"Example for the variable.\",\n          \"type\": \"string\"\n        },\n        {\n          \"description\": \"Example for the variable.\",\n          \"type\": \"string\"\n        }\n      ],\n      \"request\": {\n        \"allow_insecure\": false,\n        \"basicAuth\": {\n          \"password\": \"PaSSw0RD!\",\n          \"username\": \"my_username\",\n          \"type\": \"web\"\n        },\n        \"body\": \"proident\",\n        \"bodyType\": \"text/plain\",\n        \"callType\": \"unary\",\n        \"certificate\": {\n          \"cert\": {\n            \"content\": \"reprehenderit labore Ut sed mollit\",\n            \"filename\": \"Duis consectetur incididunt eiusmod\",\n            \"updatedAt\": \"aliquip in\"\n          },\n          \"key\": {\n            \"content\": \"consequat sint nulla aute aliquip\",\n            \"filename\": \"non nisi\",\n            \"updatedAt\": \"et\"\n          }\n        },\n        \"compressedJsonDescriptor\": \"dolore\",\n        \"dnsServer\": \"elit nostrud in adipisic\",\n        \"dnsServerPort\": 60578,\n        \"follow_redirects\": false,\n        \"headers\": {\n          \"proident_69\": \"quis dolor occaecat\"\n        },\n        \"host\": \"laborum laboris\",\n        \"message\": \"aliqua ea laborum laboris\",\n        \"metadata\": {\n          \"dolor_d\": \"veniam nostrud anim nulla\",\n          \"labore_7c6\": \"consequat eu\",\n          \"sed002\": \"Excepteur eiusmod adipisicing\"\n        },\n        \"method\": \"et irure\",\n        \"noSavingResponseBody\": false,\n        \"numberOfPackets\": 9,\n        \"persistCookies\": false,\n        \"port\": 99104800,\n        \"proxy\": {\n          \"url\": \"https://example.com\",\n          \"headers\": {\n            \"ead\": \"i\"\n          }\n        },\n        \"query\": {},\n        \"servername\": \"cillum enim adipisicing\",\n        \"service\": \"Greeter\",\n        \"shouldTrackHops\": true,\n        \"timeout\": -43666416.92792323,\n        \"url\": \"https://example.com\"\n      },\n      \"variables\": [\n        {\n          \"description\": \"Example for the variable.\",\n          \"type\": \"string\"\n        },\n        {\n          \"description\": \"Example for the variable.\",\n          \"type\": \"string\"\n        }\n      ]\n    }\n  },\n  \"check_time\": -61984290.348021574,\n  \"check_version\": -35585398,\n  \"probe_dc\": \"Duis aute\",\n  \"result\": {\n    \"cert\": {\n      \"cipher\": \"laborum dolore elit reprehenderit\",\n      \"exponent\": -97057115.16341409,\n      \"extKeyUsage\": [\n        \"e\",\n        \"non nulla\"\n      ],\n      \"fingerprint\": \"enim\",\n      \"fingerprint256\": \"commodo Duis elit culpa\",\n      \"issuer\": {\n        \"C\": \"id\",\n        \"CN\": \"dolor esse\",\n        \"L\": \"Lorem magna\",\n        \"O\": \"adipisicing ullamco\",\n        \"OU\": \"nostrud labore\",\n        \"ST\": \"proident consequat ut\"\n      },\n      \"modulus\": \"ut dolore cupidatat officia\",\n      \"protocol\": \"cillum dolor commodo sit\",\n      \"serialNumber\": \"velit\",\n      \"subject\": {\n        \"C\": \"aliquip ad voluptate\",\n        \"CN\": \"irure\",\n        \"L\": \"elit\",\n        \"O\": \"in\",\n        \"OU\": \"cillum dolor dolor aliquip nulla\",\n        \"ST\": \"mollit velit et\",\n        \"altName\": \"veniam eu mollit irure\"\n      },\n      \"validFrom\": \"1993-10-19T21:25:09.532Z\",\n      \"validTo\": \"2015-01-05T06:21:16.689Z\"\n    },\n    \"eventType\": \"finished_with_error\",\n    \"failure\": {\n      \"code\": \"DECRYPTION\",\n      \"message\": \"Error during DNS resolution (ENOTFOUND).\"\n    },\n    \"httpStatusCode\": 81890255,\n    \"requestHeaders\": {\n      \"Ut2\": {},\n      \"ad_29\": {}\n    },\n    \"responseBody\": \"Excepteur laboris Ut dolor\",\n    \"responseHeaders\": {\n      \"ut19b\": {\n        \"description\": \"Returned request header.\"\n      },\n      \"Ut_270\": {\n        \"description\": \"Returned request header.\"\n      }\n    },\n    \"responseSize\": -51226186,\n    \"timings\": {\n      \"dns\": 31944439.48881416,\n      \"download\": -87539924.41719314,\n      \"firstByte\": -96589047.25818287,\n      \"handshake\": 84645232.54590705,\n      \"redirect\": -32741896.0310553,\n      \"ssl\": -93300794.33204812,\n      \"tcp\": 65643.03422442079,\n      \"total\": 82914630.9958055,\n      \"wait\": 29723058.510239527\n    }\n  },\n  \"result_id\": \"culpa adipisicing consectetur sit\",\n  \"status\": 1\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/:public_id/results/:result_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            ":public_id",
            "results",
            ":result_id"
          ],
          "variable": [
            {
              "key": "public_id"
            },
            {
              "key": "result_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 or result 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/:public_id/results/:result_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            ":public_id",
            "results",
            ":result_id"
          ],
          "variable": [
            {
              "key": "public_id"
            },
            {
              "key": "result_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/:public_id/results/:result_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "synthetics",
            "tests",
            ":public_id",
            "results",
            ":result_id"
          ],
          "variable": [
            {
              "key": "public_id"
            },
            {
              "key": "result_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}"
    }
  ]
}