Chilkat Online Tools

DataFlex / Zoom API / Add assistants

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vReq
    Handle hoReq
    Handle hoJsonFormData1
    Variant vJsonObj_1
    Handle hoJsonObj_1
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sIds
    String sAdd_at
    String sTemp1
    Integer iTemp1
    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/assistants"
    Set ComContentType Of hoReq To "multipart/form-data"

    Get Create (RefClass(cComChilkatJsonArray)) To hoJsonFormData1
    If (Not(IsComObjectCreated(hoJsonFormData1))) Begin
        Send CreateComObject of hoJsonFormData1
    End

    Get ComAddObjectAt Of hoJsonFormData1 -1 To iSuccess
    Get ComSize Of hoJsonFormData1 To iTemp1
    Get ComObjectAt Of hoJsonFormData1 (iTemp1 - 1) To vJsonObj_1
    If (IsComObject(vJsonObj_1)) Begin
        Get Create (RefClass(cComChilkatJsonObject)) To hoJsonObj_1
        Set pvComObject Of hoJsonObj_1 To vJsonObj_1
    End
    Get ComUpdateString Of hoJsonObj_1 "id" "nisi ut aliqua" To iSuccess
    Get ComUpdateString Of hoJsonObj_1 "email" "anim" To iSuccess
    Send Destroy of hoJsonObj_1

    Get ComAddObjectAt Of hoJsonFormData1 -1 To iSuccess
    Get ComSize Of hoJsonFormData1 To iTemp1
    Get ComObjectAt Of hoJsonFormData1 (iTemp1 - 1) To vJsonObj_1
    If (IsComObject(vJsonObj_1)) Begin
        Get Create (RefClass(cComChilkatJsonObject)) To hoJsonObj_1
        Set pvComObject Of hoJsonObj_1 To vJsonObj_1
    End
    Get ComUpdateString Of hoJsonObj_1 "id" "anim ex labore proident" To iSuccess
    Get ComUpdateString Of hoJsonObj_1 "email" "tempor amet consectetur" To iSuccess
    Send Destroy of hoJsonObj_1

    Get ComEmit Of hoJsonFormData1 To sTemp1
    Send ComAddParam To hoReq "assistants" sTemp1

    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)

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

    Get ComStringOf Of hoJResp "ids" To sIds
    Get ComStringOf Of hoJResp "add_at" To sAdd_at


End_Procedure

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