Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// 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": "amir.khan@embrace-devops.com",
// "role_groups": [
// {
// "role_group_id": "e6263c45-738d-4e33-8286-f28b6d3e6f7c",
// "name": "API Versions Owner"
// }
// ]
// }
// ]
let jarr = CkoJsonArray()!
jarr.addObject(at: -1)
var jsonObj_1: CkoJsonObject? = jarr.object(at: jarr.size.intValue - 1)
jsonObj_1!.update("email", value: "amir.khan@embrace-devops.com")
jsonObj_1!.update("role_groups[0].role_group_id", value: "e6263c45-738d-4e33-8286-f28b6d3e6f7c")
jsonObj_1!.update("role_groups[0].name", value: "API Versions Owner")
jsonObj_1 = nil
// Adds the "Authorization: Bearer {{token}}" header.
http.authToken = "{{token}}"
let sbRequestBody = CkoStringBuilder()!
jarr.emitSb(sbRequestBody)
var resp: CkoHttpResponse? = http.pTextSb("POST", url: "https://domain.com/accounts/api/organizations/{{organization_id}}/invites", textData: sbRequestBody, charset: "utf-8", contentType: "application/json", md5: false, gzip: false)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp!.statusCode.intValue)")
print("\(resp!.bodyStr!)")
resp = nil
}
Curl Command
curl -X POST
-H "Authorization: Bearer {{token}}"
-d '[
{
"email":"amir.khan@embrace-devops.com",
"role_groups":
[
{
"role_group_id":"e6263c45-738d-4e33-8286-f28b6d3e6f7c",
"name":"API Versions Owner"
}
]
}
]'
https://domain.com/accounts/api/organizations/{{organization_id}}/invites
Postman Collection Item JSON
{
"name": "Invite users",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "[\r\n {\r\n \"email\":\"amir.khan@embrace-devops.com\",\r\n \"role_groups\":\r\n [\r\n {\r\n \"role_group_id\":\"e6263c45-738d-4e33-8286-f28b6d3e6f7c\",\r\n \"name\":\"API Versions Owner\"\r\n }\r\n ]\r\n }\r\n]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/accounts/api/organizations/{{organization_id}}/invites",
"host": [
"{{url}}"
],
"path": [
"accounts",
"api",
"organizations",
"{{organization_id}}",
"invites"
]
}
},
"response": [
]
}