Chilkat Online Tools

PowerBuilder / Squadcast API V3 / Get All Services

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_Name
string ls_Slug
string ls_Email
string ls_Escalation_policy_id
string ls_Organization_id
string ls_Api_key
string ls_Description
string ls_Depends
string ls_Id
string ls_Name
string ls_Description
string ls_Slug
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
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("name","")

loo_Http.SetRequestHeader("Authorization","")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api.squadcast.com/v3/services",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

i = 0
li_Count_i = loo_JResp.SizeOfArray("data")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Id = loo_JResp.StringOf("data[i].id")
    ls_Name = loo_JResp.StringOf("data[i].name")
    ls_Slug = loo_JResp.StringOf("data[i].slug")
    ls_Email = loo_JResp.StringOf("data[i].email")
    ls_Escalation_policy_id = loo_JResp.StringOf("data[i].escalation_policy_id")
    ls_Organization_id = loo_JResp.StringOf("data[i].organization_id")
    ls_Api_key = loo_JResp.StringOf("data[i].api_key")
    ls_Description = loo_JResp.StringOf("data[i].description")
    ls_Depends = loo_JResp.StringOf("data[i].depends")
    ls_Id = loo_JResp.StringOf("data[i].escalation_policy.id")
    ls_Name = loo_JResp.StringOf("data[i].escalation_policy.name")
    ls_Description = loo_JResp.StringOf("data[i].escalation_policy.description")
    ls_Slug = loo_JResp.StringOf("data[i].escalation_policy.slug")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

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}"
    }
  ]
}