Chilkat Online Tools

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

Back to Collection Items

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oReq = ObjCreate("Chilkat.HttpRequest")
$oReq.HttpVerb = "POST"
$oReq.Path = "/v2/users/:userId/tsp"
$oReq.ContentType = "multipart/form-data"
$oReq.AddParam "conference_code","dolore elit"

$oReq.AddParam "leader_pin","dolore elitipsu"

$oReq.AddParam "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"":""""}]"

$oReq.AddParam "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"

$oReq.AddHeader "Authorization","Bearer <access_token>"

Local $oResp = $oHttp.SynchronousRequest("api.zoom.us",443,True,$oReq)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Failed." & @CRLF)

    Exit
EndIf

; 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

Local $sCode
Local $sV_number
Local $sV_type

Local $sConference_code = $oJResp.StringOf("conference_code")
Local $sLeader_pin = $oJResp.StringOf("leader_pin")
Local $sTsp_bridge = $oJResp.StringOf("tsp_bridge")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("dial_in_numbers")
While $i < $iCount_i
    $oJResp.I = $i
    $sCode = $oJResp.StringOf("dial_in_numbers[i].code")
    $sV_number = $oJResp.StringOf("dial_in_numbers[i].number")
    $sV_type = $oJResp.StringOf("dial_in_numbers[i].type")
    $i = $i + 1
Wend

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": ""
    }
  ]
}