Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_type
integer li_Time
string ls_Id
string ls_First_name
string ls_Last_name
string ls_V_Email
string ls_Dial_code
string ls_Phone_number
string ls_Secondary_emails
integer li_Email_verified
string ls_Time_zone
string ls_Title
string ls_Bio
integer li_User_image
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
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "email": "<string>",
// "role": "<string>",
// "first_name": "<string>",
// "last_name": "<string>"
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateString("email","<string>")
loo_Json.UpdateString("role","<string>")
loo_Json.UpdateString("first_name","<string>")
loo_Json.UpdateString("last_name","<string>")
loo_Http.SetRequestHeader("Authorization","")
loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Resp = loo_Http.PostJson3("https://api.squadcast.com/v3/users","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
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_Json
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": "5e9c204dbde1298f6bcb5ef2",
// "first_name": "Manigandan",
// "last_name": "Dharmalingam",
// "email": "manigandan@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
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Id = loo_JResp.StringOf("data.id")
ls_First_name = loo_JResp.StringOf("data.first_name")
ls_Last_name = loo_JResp.StringOf("data.last_name")
ls_V_Email = loo_JResp.StringOf("data.email")
ls_Dial_code = loo_JResp.StringOf("data.contact.dial_code")
ls_Phone_number = loo_JResp.StringOf("data.contact.phone_number")
ls_Secondary_emails = loo_JResp.StringOf("data.secondary_emails")
li_Email_verified = loo_JResp.BoolOf("data.email_verified")
ls_Time_zone = loo_JResp.StringOf("data.time_zone")
ls_Title = loo_JResp.StringOf("data.title")
ls_Bio = loo_JResp.StringOf("data.bio")
li_User_image = loo_JResp.BoolOf("data.user_image")
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.notification_rules")
do while i < li_Count_i
loo_JResp.I = i
ls_V_type = loo_JResp.StringOf("data.notification_rules[i].type")
li_Time = loo_JResp.IntOf("data.notification_rules[i].time")
i = i + 1
loop
destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X POST
-H "Authorization: "
-H "Content-Type: application/json"
-d '{
"email": "<string>",
"role": "<string>",
"first_name": "<string>",
"last_name": "<string>"
}'
https://api.squadcast.com/v3/users
Postman Collection Item JSON
{
"name": "Add User",
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Authorization",
"value": ""
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"<string>\",\n \"role\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
},
"description": "Add user to the organization with given role if not exists. Returns the user object in response. \nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `user-write` scope."
},
"response": [
{
"name": "Unprocessable Entity",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Unprocessable Entity (WebDAV) (RFC 4918)",
"code": 422,
"_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": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"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": "Created",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"id\": \"5e9c204dbde1298f6bcb5ef2\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\",\n \"email\": \"manigandan@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 }\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 400,\n \"error_message\": \"email required\"\n }\n}"
},
{
"name": "Conflict",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Conflict",
"code": 409,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 409,\n \"error_message\": \"cannot add same user manigandan2293@gmail.com again to the organization\"\n }\n}"
},
{
"name": "Unauthorized",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"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\": 401,\n \"error_message\": \"invalid access token\"\n }\n}"
},
{
"name": "Forbidden",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"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}"
}
]
}