Chilkat Online Tools

Foxpro / Zoom API / Add assistants

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loReq
LOCAL loJsonFormData1
LOCAL loJsonObj_1
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcIds
LOCAL lcAdd_at

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

loReq = CreateObject('Chilkat_9_5_0.HttpRequest')
loReq.HttpVerb = "POST"
loReq.Path = "/v2/users/:userId/assistants"
loReq.ContentType = "multipart/form-data"

loJsonFormData1 = CreateObject('Chilkat_9_5_0.JsonArray')

loJsonFormData1.AddObjectAt(-1)
loJsonObj_1 = loJsonFormData1.ObjectAt(loJsonFormData1.Size - 1)
loJsonObj_1.UpdateString("id","nisi ut aliqua")
loJsonObj_1.UpdateString("email","anim")
RELEASE loJsonObj_1

loJsonFormData1.AddObjectAt(-1)
loJsonObj_1 = loJsonFormData1.ObjectAt(loJsonFormData1.Size - 1)
loJsonObj_1.UpdateString("id","anim ex labore proident")
loJsonObj_1.UpdateString("email","tempor amet consectetur")
RELEASE loJsonObj_1

loReq.AddParam("assistants",loJsonFormData1.Emit())

loReq.AddHeader("Authorization","Bearer <access_token>")

loResp = loHttp.SynchronousRequest("api.zoom.us",443,1,loReq)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loReq
    RELEASE loJsonFormData1
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loReq
    RELEASE loJsonFormData1
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "ids": "string",
*   "add_at": "string [date-time]"
* }

* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

lcIds = loJResp.StringOf("ids")
lcAdd_at = loJResp.StringOf("add_at")

RELEASE loHttp
RELEASE loReq
RELEASE loJsonFormData1
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: multipart/form-data"
	--form 'assistants=[{"id":"nisi ut aliqua","email":"anim"},{"id":"anim ex labore proident","email":"tempor amet consectetur"}]'
https://api.zoom.us/v2/users/:userId/assistants

Postman Collection Item JSON

{
  "name": "Add assistants",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "assistants",
          "value": "[{\"id\":\"nisi ut aliqua\",\"email\":\"anim\"},{\"id\":\"anim ex labore proident\",\"email\":\"tempor amet consectetur\"}]",
          "description": "List of User's assistants.",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/users/:userId/assistants",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "users",
        ":userId",
        "assistants"
      ],
      "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": "Use this API to assign assistants to a user. In the request body, provide either the user's ID or the user's email address. For user-level apps, pass [the `me` value](https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#mekeyword) instead of the `userId` parameter. \n\n Assistants are users to whom the current user has assigned the [scheduling privilege](https://support.zoom.us/hc/en-us/articles/201362803-Scheduling-Privilege). These assistants can schedule meetings on behalf of the current user. Assistants can also manage and act as an alternative host for the user's meetings if the administrator has enabled the [co-host feature](https://support.zoom.us/hc/en-us/articles/206330935-Enabling-and-adding-a-co-host) on the account.\n\n**Scopes:** `user:write:admin`, `user:write` </br> **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium` \n\n**Prerequisites:** \n* The user and the assistant must have a Licensed or an On-prem license. \n* Assistants must be under the current user's account or in the same organization with the current user's account."
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `201`<br>\nAssistant added.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "assistants",
              "value": "[{\"id\":\"in nulla consequat\",\"email\":\"tempor ullamco occaecat et\"},{\"id\":\"nostrud incididunt et nisi\",\"email\":\"aute Excepteur laborum aliquip magna\"}]",
              "description": "List of User's assistants.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/users/:userId/assistants",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId",
            "assistants"
          ],
          "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-Location",
          "value": "quis officia in reprehenderit",
          "description": "Location of created assistant"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"ids\": \"string\",\n \"add_at\": \"string [date-time]\"\n}"
    },
    {
      "name": "**HTTP Status Code:** `400` **Bad Request**<br><br>\n**Error Code:** `200`<br>\nCurrent account must be paid account: $userId <br>\nThe user must either be a Licensed user or an On-prem user : $userId. <br>\nCan't assign scheduling privilege to yourself.<br>\n",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "assistants",
              "value": "[{\"id\":\"in nulla consequat\",\"email\":\"tempor ullamco occaecat et\"},{\"id\":\"nostrud incididunt et nisi\",\"email\":\"aute Excepteur laborum aliquip magna\"}]",
              "description": "List of User's assistants.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/users/:userId/assistants",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId",
            "assistants"
          ],
          "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` **Not Found**<br>\n**Error Code:** `1001`<br>\nUser does not exist: $userId.<br>",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "assistants",
              "value": "[{\"id\":\"in nulla consequat\",\"email\":\"tempor ullamco occaecat et\"},{\"id\":\"nostrud incididunt et nisi\",\"email\":\"aute Excepteur laborum aliquip magna\"}]",
              "description": "List of User's assistants.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/users/:userId/assistants",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId",
            "assistants"
          ],
          "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": ""
    }
  ]
}