Chilkat Online Tools

PowerBuilder / Squadcast API V3 / Get All Users

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_First_name
string ls_Last_name
string ls_Email
string ls_Dial_code
string ls_Phone_number
integer li_Email_verified
string ls_Time_zone
string ls_Title
string ls_Bio
integer li_User_image
string ls_Role_id
string ls_Role
string ls_Secondary_emails
integer j
integer li_Count_j
string ls_V_type
integer li_Time
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_Http.SetRequestHeader("Authorization","")

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

li_Success = loo_Http.QuickGetSb("https://api.squadcast.com/v3/users",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
// 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_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)

// {
//   "data": [
//     {
//       "id": "5d81d9187000fb6b9def7e31",
//       "first_name": "Manigandan",
//       "last_name": "Dharmalingam",
//       "email": "manigandan@squadcast.com",
//       "contact": {
//         "dial_code": "+91",
//         "phone_number": "9578628779"
//       },
//       "secondary_emails": [
//       ],
//       "email_verified": true,
//       "time_zone": "Asia/Calcutta",
//       "title": "",
//       "bio": "",
//       "notification_rules": [
//         {
//           "type": "Email",
//           "time": 0
//         },
//         {
//           "type": "Push",
//           "time": 0
//         },
//         {
//           "type": "SMS",
//           "time": 1
//         },
//         {
//           "type": "Phone",
//           "time": 2
//         }
//       ],
//       "user_image": false,
//       "role_id": "5a425b383c36823b3ed91fb4",
//       "role": "account_owner"
//     },
//     {
//       "id": "5d91d262a2c85fa24a27d4d7",
//       "first_name": "Akilan",
//       "last_name": "Elango",
//       "email": "akilan@squadcast.com",
//       "contact": {
//         "dial_code": "",
//         "phone_number": ""
//       },
//       "secondary_emails": null,
//       "email_verified": false,
//       "time_zone": "",
//       "title": "",
//       "bio": "",
//       "notification_rules": [
//         {
//           "type": "Email",
//           "time": 0
//         },
//         {
//           "type": "Push",
//           "time": 0
//         },
//         {
//           "type": "SMS",
//           "time": 1
//         },
//         {
//           "type": "Phone",
//           "time": 2
//         }
//       ],
//       "user_image": false,
//       "role_id": "5a425b383c36823b3ed91fb5",
//       "role": "admin"
//     },
//     {
//       "id": "5d91d262a2c85fa24a27d4da",
//       "first_name": "Madhu",
//       "last_name": "DS Frontend",
//       "email": "madhu@squadcast.com",
//       "contact": {
//         "dial_code": "",
//         "phone_number": ""
//       },
//       "secondary_emails": null,
//       "email_verified": false,
//       "time_zone": "",
//       "title": "",
//       "bio": "",
//       "notification_rules": [
//         {
//           "type": "Email",
//           "time": 0
//         },
//         {
//           "type": "Push",
//           "time": 0
//         },
//         {
//           "type": "SMS",
//           "time": 1
//         },
//         {
//           "type": "Phone",
//           "time": 2
//         }
//       ],
//       "user_image": false,
//       "role_id": "5a425b383c36823b3ed91fb6",
//       "role": "user"
//     }
//   ]
// }

// 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_First_name = loo_JResp.StringOf("data[i].first_name")
    ls_Last_name = loo_JResp.StringOf("data[i].last_name")
    ls_Email = loo_JResp.StringOf("data[i].email")
    ls_Dial_code = loo_JResp.StringOf("data[i].contact.dial_code")
    ls_Phone_number = loo_JResp.StringOf("data[i].contact.phone_number")
    li_Email_verified = loo_JResp.BoolOf("data[i].email_verified")
    ls_Time_zone = loo_JResp.StringOf("data[i].time_zone")
    ls_Title = loo_JResp.StringOf("data[i].title")
    ls_Bio = loo_JResp.StringOf("data[i].bio")
    li_User_image = loo_JResp.BoolOf("data[i].user_image")
    ls_Role_id = loo_JResp.StringOf("data[i].role_id")
    ls_Role = loo_JResp.StringOf("data[i].role")
    ls_Secondary_emails = loo_JResp.StringOf("data[i].secondary_emails")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("data[i].secondary_emails")
    do while j < li_Count_j
        loo_JResp.J = j
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("data[i].notification_rules")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_V_type = loo_JResp.StringOf("data[i].notification_rules[j].type")
        li_Time = loo_JResp.IntOf("data[i].notification_rules[j].time")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X GET
	-H "Authorization: "
https://api.squadcast.com/v3/users

Postman Collection Item JSON

{
  "name": "Get All Users",
  "request": {
    "auth": {
      "type": "noauth"
    },
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": ""
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/users",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "users"
      ]
    },
    "description": "Returns all the users of the organization.\nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `read` scope.\n        "
  },
  "response": [
    {
      "name": "Forbidden",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/users",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"meta\": {\n  \"status\": \"<integer>\",\n  \"error_message\": \"<string>\"\n }\n}"
    },
    {
      "name": "Internal Server Error",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/users",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users"
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"meta\": {\n  \"status\": \"<integer>\",\n  \"error_message\": \"<string>\"\n }\n}"
    },
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/users",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"data\": [\n  {\n   \"id\": \"5d81d9187000fb6b9def7e31\",\n   \"first_name\": \"Manigandan\",\n   \"last_name\": \"Dharmalingam\",\n   \"email\": \"manigandan@squadcast.com\",\n   \"contact\": {\n    \"dial_code\": \"+91\",\n    \"phone_number\": \"9578628779\"\n   },\n   \"secondary_emails\": [],\n   \"email_verified\": true,\n   \"time_zone\": \"Asia/Calcutta\",\n   \"title\": \"\",\n   \"bio\": \"\",\n   \"notification_rules\": [\n    {\n     \"type\": \"Email\",\n     \"time\": 0\n    },\n    {\n     \"type\": \"Push\",\n     \"time\": 0\n    },\n    {\n     \"type\": \"SMS\",\n     \"time\": 1\n    },\n    {\n     \"type\": \"Phone\",\n     \"time\": 2\n    }\n   ],\n   \"user_image\": false,\n   \"role_id\": \"5a425b383c36823b3ed91fb4\",\n   \"role\": \"account_owner\"\n  },\n  {\n   \"id\": \"5d91d262a2c85fa24a27d4d7\",\n   \"first_name\": \"Akilan\",\n   \"last_name\": \"Elango\",\n   \"email\": \"akilan@squadcast.com\",\n   \"contact\": {\n    \"dial_code\": \"\",\n    \"phone_number\": \"\"\n   },\n   \"secondary_emails\": null,\n   \"email_verified\": false,\n   \"time_zone\": \"\",\n   \"title\": \"\",\n   \"bio\": \"\",\n   \"notification_rules\": [\n    {\n     \"type\": \"Email\",\n     \"time\": 0\n    },\n    {\n     \"type\": \"Push\",\n     \"time\": 0\n    },\n    {\n     \"type\": \"SMS\",\n     \"time\": 1\n    },\n    {\n     \"type\": \"Phone\",\n     \"time\": 2\n    }\n   ],\n   \"user_image\": false,\n   \"role_id\": \"5a425b383c36823b3ed91fb5\",\n   \"role\": \"admin\"\n  },\n  {\n   \"id\": \"5d91d262a2c85fa24a27d4da\",\n   \"first_name\": \"Madhu\",\n   \"last_name\": \"DS Frontend\",\n   \"email\": \"madhu@squadcast.com\",\n   \"contact\": {\n    \"dial_code\": \"\",\n    \"phone_number\": \"\"\n   },\n   \"secondary_emails\": null,\n   \"email_verified\": false,\n   \"time_zone\": \"\",\n   \"title\": \"\",\n   \"bio\": \"\",\n   \"notification_rules\": [\n    {\n     \"type\": \"Email\",\n     \"time\": 0\n    },\n    {\n     \"type\": \"Push\",\n     \"time\": 0\n    },\n    {\n     \"type\": \"SMS\",\n     \"time\": 1\n    },\n    {\n     \"type\": \"Phone\",\n     \"time\": 2\n    }\n   ],\n   \"user_image\": false,\n   \"role_id\": \"5a425b383c36823b3ed91fb6\",\n   \"role\": \"user\"\n  }\n ]\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/users",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"meta\": {\n  \"status\": \"<integer>\",\n  \"error_message\": \"<string>\"\n }\n}"
    }
  ]
}