Chilkat Online Tools

DataFlex / Squadcast API V3 / Get All Services

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 sId
    String sName
    String sSlug
    String sEmail
    String sEscalation_policy_id
    String sOrganization_id
    String sApi_key
    String sDescription
    String sDepends
    String sId
    String sName
    String sDescription
    String sSlug
    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 "name" "" To iSuccess

    Send ComSetRequestHeader To hoHttp "Authorization" ""

    Get pvComObject of hoQueryParams to vQueryParams
    Get ComQuickRequestParams Of hoHttp "GET" "https://api.squadcast.com/v3/services" 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": [
    //     {
    //       "id": "5e8edb24668e003cb0b18ba1",
    //       "name": "Payment API Service",
    //       "slug": "payment-api-service",
    //       "email": "unique_string@gopherhut.incidents.squadcast.com",
    //       "escalation_policy_id": "5d81d9407000fb6b9def7e33",
    //       "organization_id": "5d81d9187000fb6b9def7e32",
    //       "api_key": "2f81ac8b2362990dd220f8bb4f7cd30ccc3dac43",
    //       "description": "Payment API Service monitor",
    //       "depends": null,
    //       "escalation_policy": {
    //         "id": "5d81d9407000fb6b9def7e33",
    //         "name": "Example Escalation Policy",
    //         "description": "On-Boarding Example",
    //         "slug": "example-escalation-policy"
    //       }
    //     },
    //     {
    //       "id": "5e8edb24668e003cb0b18ba2",
    //       "name": "Notification Service",
    //       "slug": "notification-api-service",
    //       "email": "unique_string@gopherhut.incidents.squadcast.com",
    //       "escalation_policy_id": "5d81d9407000fb6b9def7e33",
    //       "organization_id": "5d81d9187000fb6b9def7e32",
    //       "api_key": "2f81ac8b2362990dd220f8bb4f7cd30ccc3d43",
    //       "description": "Notification API Service monitor",
    //       "depends": null,
    //       "escalation_policy": {
    //         "id": "5d81d9407000fb6b9def7e33",
    //         "name": "Example Escalation Policy",
    //         "description": "On-Boarding Example",
    //         "slug": "example-escalation-policy"
    //       }
    //     }
    //   ]
    // }

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

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "data" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "data[i].id" To sId
        Get ComStringOf Of hoJResp "data[i].name" To sName
        Get ComStringOf Of hoJResp "data[i].slug" To sSlug
        Get ComStringOf Of hoJResp "data[i].email" To sEmail
        Get ComStringOf Of hoJResp "data[i].escalation_policy_id" To sEscalation_policy_id
        Get ComStringOf Of hoJResp "data[i].organization_id" To sOrganization_id
        Get ComStringOf Of hoJResp "data[i].api_key" To sApi_key
        Get ComStringOf Of hoJResp "data[i].description" To sDescription
        Get ComStringOf Of hoJResp "data[i].depends" To sDepends
        Get ComStringOf Of hoJResp "data[i].escalation_policy.id" To sId
        Get ComStringOf Of hoJResp "data[i].escalation_policy.name" To sName
        Get ComStringOf Of hoJResp "data[i].escalation_policy.description" To sDescription
        Get ComStringOf Of hoJResp "data[i].escalation_policy.slug" To sSlug
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -G -d "name="
	-H "Authorization: "
https://api.squadcast.com/v3/services

Postman Collection Item JSON

{
  "name": "Get All Services",
  "request": {
    "auth": {
      "type": "noauth"
    },
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": ""
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/services?name=",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "services"
      ],
      "query": [
        {
          "key": "name",
          "value": ""
        }
      ]
    },
    "description": "Returns all the active services for the organization.\nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `read` scope.\n\nQuery Param:\n\n`name`: get a service by name"
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/services",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "services"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"data\": [\n  {\n   \"id\": \"5e8edb24668e003cb0b18ba1\",\n   \"name\": \"Payment API Service\",\n   \"slug\": \"payment-api-service\",\n   \"email\": \"unique_string@gopherhut.incidents.squadcast.com\",\n   \"escalation_policy_id\": \"5d81d9407000fb6b9def7e33\",\n   \"organization_id\": \"5d81d9187000fb6b9def7e32\",\n   \"api_key\": \"2f81ac8b2362990dd220f8bb4f7cd30ccc3dac43\",\n   \"description\": \"Payment API Service monitor\",\n   \"depends\": null,\n   \"escalation_policy\": {\n    \"id\": \"5d81d9407000fb6b9def7e33\",\n    \"name\": \"Example Escalation Policy\",\n    \"description\": \"On-Boarding Example\",\n    \"slug\": \"example-escalation-policy\"\n   }\n  },\n  {\n   \"id\": \"5e8edb24668e003cb0b18ba2\",\n   \"name\": \"Notification Service\",\n   \"slug\": \"notification-api-service\",\n   \"email\": \"unique_string@gopherhut.incidents.squadcast.com\",\n   \"escalation_policy_id\": \"5d81d9407000fb6b9def7e33\",\n   \"organization_id\": \"5d81d9187000fb6b9def7e32\",\n   \"api_key\": \"2f81ac8b2362990dd220f8bb4f7cd30ccc3d43\",\n   \"description\": \"Notification API Service monitor\",\n   \"depends\": null,\n   \"escalation_policy\": {\n    \"id\": \"5d81d9407000fb6b9def7e33\",\n    \"name\": \"Example Escalation Policy\",\n    \"description\": \"On-Boarding Example\",\n    \"slug\": \"example-escalation-policy\"\n   }\n  }\n ]\n}"
    }
  ]
}