Chilkat Online Tools

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

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vReq
    Handle hoReq
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sCode
    String sV_number
    String sV_type
    String sConference_code
    String sLeader_pin
    String sTsp_bridge
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "POST"
    Set ComPath Of hoReq To "/v2/users/:userId/tsp"
    Set ComContentType Of hoReq To "multipart/form-data"
    Send ComAddParam To hoReq "conference_code" "dolore elit"

    Send ComAddParam To hoReq "leader_pin" "dolore elitipsu"

    Send ComAddParam To hoReq "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":""}]'

    Send ComAddParam To hoReq "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'

    Send ComAddHeader To hoReq "Authorization" "Bearer <access_token>"

    Get pvComObject of hoReq to vReq
    Get ComSynchronousRequest Of hoHttp "api.zoom.us" 443 True vReq To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    Get ComStringOf Of hoJResp "conference_code" To sConference_code
    Get ComStringOf Of hoJResp "leader_pin" To sLeader_pin
    Get ComStringOf Of hoJResp "tsp_bridge" To sTsp_bridge
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "dial_in_numbers" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "dial_in_numbers[i].code" To sCode
        Get ComStringOf Of hoJResp "dial_in_numbers[i].number" To sV_number
        Get ComStringOf Of hoJResp "dial_in_numbers[i].type" To sV_type
        Move (i + 1) To i
    Loop



End_Procedure

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