Objective-C / Zoom API / Add a user's TSP account
Back to Collection Items
#import <CkoHttp.h>
#import <CkoHttpRequest.h>
#import <CkoHttpResponse.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
CkoHttpRequest *req = [[CkoHttpRequest alloc] init];
req.HttpVerb = @"POST";
req.Path = @"/v2/users/:userId/tsp";
req.ContentType = @"multipart/form-data";
[req AddParam: @"conference_code" value: @"dolore elit"];
[req AddParam: @"leader_pin" value: @"dolore elitipsu"];
[req AddParam: @"dial_in_numbers" value: @"dolore elitipsu[{\"code\":\"sin\",\"number\":\"voluptat\",\"type\":\"toll\",\"country_label\":\"in deserun\"},{\"code\":\"a\",\"number\":\"ea pariatur in i\",\"type\":\"tollfree\",\"country_label\":\"\"}]"];
[req AddParam: @"tsp_bridge" value: @"dolore elitipsu[{\"code\":\"sin\",\"number\":\"voluptat\",\"type\":\"toll\",\"country_label\":\"in deserun\"},{\"code\":\"a\",\"number\":\"ea pariatur in i\",\"type\":\"tollfree\",\"country_label\":\"\"}]US_TSP_TB"];
[req AddHeader: @"Authorization" value: @"Bearer <access_token>"];
CkoHttpResponse *resp = [http SynchronousRequest: @"api.zoom.us" port: [NSNumber numberWithInt: 443] ssl: YES req: req];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
[resp GetBodySb: sbResponseBody];
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);
int respStatusCode = [resp.StatusCode intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",resp.Header);
NSLog(@"%@",@"Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "conference_code": "0125",
// "leader_pin": "11189898",
// "tsp_bridge": "string",
// "dial_in_numbers": [
// {
// "code": "01",
// "number": "000000000",
// "type": "toll"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
NSString *code = 0;
NSString *v_number = 0;
NSString *v_type = 0;
NSString *conference_code = [jResp StringOf: @"conference_code"];
NSString *leader_pin = [jResp StringOf: @"leader_pin"];
NSString *tsp_bridge = [jResp StringOf: @"tsp_bridge"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"dial_in_numbers"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
code = [jResp StringOf: @"dial_in_numbers[i].code"];
v_number = [jResp StringOf: @"dial_in_numbers[i].number"];
v_type = [jResp StringOf: @"dial_in_numbers[i].type"];
i = i + 1;
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: multipart/form-data"
--form 'conference_code=dolore elit'
--form 'leader_pin=dolore elitipsu'
--form 'dial_in_numbers=dolore elitipsu[{"code":"sin","number":"voluptat","type":"toll","country_label":"in deserun"},{"code":"a","number":"ea pariatur in i","type":"tollfree","country_label":""}]'
--form 'tsp_bridge=dolore elitipsu[{"code":"sin","number":"voluptat","type":"toll","country_label":"in deserun"},{"code":"a","number":"ea pariatur in i","type":"tollfree","country_label":""}]US_TSP_TB'
https://api.zoom.us/v2/users/:userId/tsp
Postman Collection Item JSON
{
"name": "Add a user's TSP account",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "multipart/form-data"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "conference_code",
"value": "dolore elit ",
"description": "(Required) Conference code: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "leader_pin",
"value": "ipsu",
"description": "(Required) Leader PIN: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "dial_in_numbers",
"value": "[{\"code\":\"sin\",\"number\":\"voluptat\",\"type\":\"toll\",\"country_label\":\"in deserun\"},{\"code\":\"a\",\"number\":\"ea pariatur in i\",\"type\":\"tollfree\",\"country_label\":\"\"}]",
"description": "List of dial in numbers.",
"type": "text"
},
{
"key": "tsp_bridge",
"value": "US_TSP_TB",
"description": "Telephony bridge (This can only be one of US_TSP_TB,EU_TSP_TB)",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/users/:userId/tsp",
"host": [
"{{baseUrl}}"
],
"path": [
"users",
":userId",
"tsp"
],
"variable": [
{
"key": "userId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user ID or email address of the user. For user-level apps, pass the `me` value for this parameter."
}
]
},
"description": "Add a user's TSP account.<br><br>\n**Scopes:** `tsp:write:admin` `tsp:write`<br>\n \n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`\n"
},
"response": [
{
"name": "**HTTP Status Code:** `201`<br>\nTSP account added.",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "conference_code",
"value": "ipsum ullamco",
"description": "(Required) Conference code: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "leader_pin",
"value": "esse do",
"description": "(Required) Leader PIN: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "dial_in_numbers",
"value": "[{\"code\":\"proi\",\"number\":\"aute\",\"type\":\"media_link\",\"country_label\":\"id in ea e\"},{\"code\":\"q\",\"number\":\"vol\",\"type\":\"toll\",\"country_label\":\"amet par\"}]",
"description": "List of dial in numbers.",
"type": "text"
},
{
"key": "tsp_bridge",
"value": "US_TSP_TB",
"description": "Telephony bridge (This can only be one of US_TSP_TB,EU_TSP_TB)",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/users/:userId/tsp",
"host": [
"{{baseUrl}}"
],
"path": [
"users",
":userId",
"tsp"
],
"variable": [
{
"key": "userId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user ID or email address of the user. For user-level apps, pass the `me` value for this parameter."
}
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"conference_code\": \"0125\",\n \"leader_pin\": \"11189898\",\n \"tsp_bridge\": \"string\",\n \"dial_in_numbers\": [\n {\n \"code\": \"01\",\n \"number\": \"000000000\",\n \"type\": \"toll\"\n }\n ]\n}"
},
{
"name": "**HTTP Status Code:** `400`<br>\nBad Request.<br>\n**Error Code:**`2024`<br>\nAccount has not enabled TSP.<br>\n**Error Code:**`300`<br>\nMedia link is required for AT&T TSP accounts.<br>\n**Error Code:** `300`<br>\nYou can add a max of two tsp configs.\n",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "conference_code",
"value": "ipsum ullamco",
"description": "(Required) Conference code: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "leader_pin",
"value": "esse do",
"description": "(Required) Leader PIN: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "dial_in_numbers",
"value": "[{\"code\":\"proi\",\"number\":\"aute\",\"type\":\"media_link\",\"country_label\":\"id in ea e\"},{\"code\":\"q\",\"number\":\"vol\",\"type\":\"toll\",\"country_label\":\"amet par\"}]",
"description": "List of dial in numbers.",
"type": "text"
},
{
"key": "tsp_bridge",
"value": "US_TSP_TB",
"description": "Telephony bridge (This can only be one of US_TSP_TB,EU_TSP_TB)",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/users/:userId/tsp",
"host": [
"{{baseUrl}}"
],
"path": [
"users",
":userId",
"tsp"
],
"variable": [
{
"key": "userId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user ID or email address of the user. For user-level apps, pass the `me` value for this parameter."
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
},
{
"name": "**HTTP Status Code:** `404`<br>\nNot Found.<br>\n**Error Code:** `1001`<br>\nUser does not exist: $userId.<br>\n**Error Code:**`1120`<br>\nA valid invitation to join the Zoom account was not found for this user.<br>\nThis error is thrown if you added a user in ",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "conference_code",
"value": "ipsum ullamco",
"description": "(Required) Conference code: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "leader_pin",
"value": "esse do",
"description": "(Required) Leader PIN: numeric value, length is less than 16.",
"type": "text"
},
{
"key": "dial_in_numbers",
"value": "[{\"code\":\"proi\",\"number\":\"aute\",\"type\":\"media_link\",\"country_label\":\"id in ea e\"},{\"code\":\"q\",\"number\":\"vol\",\"type\":\"toll\",\"country_label\":\"amet par\"}]",
"description": "List of dial in numbers.",
"type": "text"
},
{
"key": "tsp_bridge",
"value": "US_TSP_TB",
"description": "Telephony bridge (This can only be one of US_TSP_TB,EU_TSP_TB)",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/users/:userId/tsp",
"host": [
"{{baseUrl}}"
],
"path": [
"users",
":userId",
"tsp"
],
"variable": [
{
"key": "userId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user ID or email address of the user. For user-level apps, pass the `me` value for this parameter."
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}