Chilkat Online Tools

Foxpro / Datadog API Collection / Get an SLO correction for an SLO

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcCategory
LOCAL lnCreated_at
LOCAL lcV_Email
LOCAL lcHandle
LOCAL lcName
LOCAL lcDescription
LOCAL lnDuration
LOCAL lnV_End
LOCAL lnModified_at
LOCAL lcModifierEmail
LOCAL lcModifierHandle
LOCAL lcModifierName
LOCAL lcRrule
LOCAL lcSlo_id
LOCAL lnStart
LOCAL lcTimezone
LOCAL lcId
LOCAL lcV_Type

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.SetRequestHeader("Accept","application/json")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://api.app.ddog-gov.com/api/v1/slo/correction/:slo_correction_id",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

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

* {
*   "data": {
*     "attributes": {
*       "category": "Scheduled Maintenance",
*       "created_at": 11806311,
*       "creator": {
*         "email": "dolor nisi",
*         "handle": "la",
*         "name": "in quis est cillum"
*       },
*       "description": "nostrud amet ea exercitation",
*       "duration": 3600,
*       "end": 30790629,
*       "modified_at": 77538107,
*       "modifier": {
*         "email": "pariatur nisi minim reprehenderit",
*         "handle": "irure commodo",
*         "name": "veniam"
*       },
*       "rrule": "FREQ=DAILY;INTERVAL=10;COUNT=5",
*       "slo_id": "incididunt qui velit sunt labore",
*       "start": -34398281,
*       "timezone": "eu id"
*     },
*     "id": "enim qui",
*     "type": "correction"
*   }
* }

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

lcCategory = loJResp.StringOf("data.attributes.category")
lnCreated_at = loJResp.IntOf("data.attributes.created_at")
lcV_Email = loJResp.StringOf("data.attributes.creator.email")
lcHandle = loJResp.StringOf("data.attributes.creator.handle")
lcName = loJResp.StringOf("data.attributes.creator.name")
lcDescription = loJResp.StringOf("data.attributes.description")
lnDuration = loJResp.IntOf("data.attributes.duration")
lnV_End = loJResp.IntOf("data.attributes.end")
lnModified_at = loJResp.IntOf("data.attributes.modified_at")
lcModifierEmail = loJResp.StringOf("data.attributes.modifier.email")
lcModifierHandle = loJResp.StringOf("data.attributes.modifier.handle")
lcModifierName = loJResp.StringOf("data.attributes.modifier.name")
lcRrule = loJResp.StringOf("data.attributes.rrule")
lcSlo_id = loJResp.StringOf("data.attributes.slo_id")
lnStart = loJResp.IntOf("data.attributes.start")
lcTimezone = loJResp.StringOf("data.attributes.timezone")
lcId = loJResp.StringOf("data.id")
lcV_Type = loJResp.StringOf("data.type")

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/slo/correction/:slo_correction_id

Postman Collection Item JSON

{
  "name": "Get an SLO correction for an SLO",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/slo/correction/:slo_correction_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "slo",
        "correction",
        ":slo_correction_id"
      ],
      "variable": [
        {
          "key": "slo_correction_id",
          "value": "tempor Ut sed velit"
        }
      ]
    },
    "description": "Get an SLO correction."
  },
  "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/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"attributes\": {\n      \"category\": \"Scheduled Maintenance\",\n      \"created_at\": 11806311,\n      \"creator\": {\n        \"email\": \"dolor nisi\",\n        \"handle\": \"la\",\n        \"name\": \"in quis est cillum\"\n      },\n      \"description\": \"nostrud amet ea exercitation\",\n      \"duration\": 3600,\n      \"end\": 30790629,\n      \"modified_at\": 77538107,\n      \"modifier\": {\n        \"email\": \"pariatur nisi minim reprehenderit\",\n        \"handle\": \"irure commodo\",\n        \"name\": \"veniam\"\n      },\n      \"rrule\": \"FREQ=DAILY;INTERVAL=10;COUNT=5\",\n      \"slo_id\": \"incididunt qui velit sunt labore\",\n      \"start\": -34398281,\n      \"timezone\": \"eu id\"\n    },\n    \"id\": \"enim qui\",\n    \"type\": \"correction\"\n  }\n}"
    },
    {
      "name": "Bad Request",
      "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/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_id"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\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/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_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": "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/slo/correction/:slo_correction_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "slo",
            "correction",
            ":slo_correction_id"
          ],
          "variable": [
            {
              "key": "slo_correction_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}"
    }
  ]
}