Chilkat Online Tools

Android / Zoom API / Add assistants

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    CkHttpRequest req = new CkHttpRequest();
    req.put_HttpVerb("POST");
    req.put_Path("/v2/users/:userId/assistants");
    req.put_ContentType("multipart/form-data");

    CkJsonArray jsonFormData1 = new CkJsonArray();

    jsonFormData1.AddObjectAt(-1);
    CkJsonObject jsonObj_1 = jsonFormData1.ObjectAt(jsonFormData1.get_Size() - 1);
    jsonObj_1.UpdateString("id","nisi ut aliqua");
    jsonObj_1.UpdateString("email","anim");

    jsonFormData1.AddObjectAt(-1);
    jsonObj_1 = jsonFormData1.ObjectAt(jsonFormData1.get_Size() - 1);
    jsonObj_1.UpdateString("id","anim ex labore proident");
    jsonObj_1.UpdateString("email","tempor amet consectetur");

    req.AddParam("assistants",jsonFormData1.emit());

    req.AddHeader("Authorization","Bearer <access_token>");

    CkHttpResponse resp = http.SynchronousRequest("api.zoom.us",443,true,req);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    resp.GetBodySb(sbResponseBody);

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = resp.get_StatusCode();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, resp.header());
        Log.i(TAG, "Failed.");

        return;
        }

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

    String ids = jResp.stringOf("ids");
    String add_at = jResp.stringOf("add_at");

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

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