Chilkat Online Tools

unicodeCpp / Zoom API / Add a user's TSP account

Back to Collection Items

#include <CkHttpW.h>
#include <CkHttpRequestW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

    CkHttpRequestW req;
    req.put_HttpVerb(L"POST");
    req.put_Path(L"/v2/users/:userId/tsp");
    req.put_ContentType(L"multipart/form-data");
    req.AddParam(L"conference_code",L"dolore elit");

    req.AddParam(L"leader_pin",L"dolore elitipsu");

    req.AddParam(L"dial_in_numbers",L"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(L"tsp_bridge",L"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(L"Authorization",L"Bearer <access_token>");

    CkHttpResponseW *resp = http.SynchronousRequest(L"api.zoom.us",443,true,req);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkStringBuilderW sbResponseBody;
    resp->GetBodySb(sbResponseBody);

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = resp->get_StatusCode();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",resp->header());
        wprintf(L"Failed.\n");
        delete resp;
        return;
    }

    delete resp;

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    const wchar_t *code = 0;
    const wchar_t *v_number = 0;
    const wchar_t *v_type = 0;

    const wchar_t *conference_code = jResp.stringOf(L"conference_code");
    const wchar_t *leader_pin = jResp.stringOf(L"leader_pin");
    const wchar_t *tsp_bridge = jResp.stringOf(L"tsp_bridge");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"dial_in_numbers");
    while (i < count_i) {
        jResp.put_I(i);
        code = jResp.stringOf(L"dial_in_numbers[i].code");
        v_number = jResp.stringOf(L"dial_in_numbers[i].number");
        v_type = jResp.stringOf(L"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": ""
    }
  ]
}