Chilkat Online Tools

Objective-C / Zoom API / Upload a user's profile picture

Back to Collection Items

#import <CkoHttp.h>
#import <CkoHttpRequest.h>
#import <CkoHttpResponse.h>

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

CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;

CkoHttpRequest *req = [[CkoHttpRequest alloc] init];
req.HttpVerb = @"POST";
req.Path = @"/v2/users/:userId/picture";
req.ContentType = @"multipart/form-data";
success = [req AddFileForUpload2: @"pic_file" path: @" path to file" contentType: @"application/octet-stream"];

[req AddHeader: @"Authorization" value: @"Bearer <access_token>"];
[req AddHeader: @"Expect" value: @"100-continue"];

CkoHttpResponse *resp = [http SynchronousRequest: @"api.zoom.us" port: [NSNumber numberWithInt: 443] ssl: YES req: req];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: multipart/form-data"
	--form 'pic_file=@"/path/to/file"'
https://api.zoom.us/v2/users/:userId/picture

Postman Collection Item JSON

{
  "name": "Upload a user's profile picture",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "pic_file",
          "description": "(Required) The file's path. ",
          "type": "file",
          "src": [
          ]
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/users/:userId/picture",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "users",
        ":userId",
        "picture"
      ],
      "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": "Upload a user's profile picture. 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\nProvide `multipart/form-data` as the value of the `content-type` header for this request. This API supports `.jpeg` and `.png` file formats.\n\n**Scopes:** `user:write:admin`, `user:write`<br>**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`"
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `201`<br>Picture uploaded.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "pic_file",
              "description": "(Required) The file's path. ",
              "type": "file",
              "src": [
              ]
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/users/:userId/picture",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId",
            "picture"
          ],
          "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": "text",
      "header": [
        {
          "key": "Content-Location",
          "value": "quis officia in reprehenderit",
          "description": "Location of user's picture"
        },
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\nBad request<br>\n**Error Code:** `300`<br>\nYour request was not accepted because the profile picture contains invalid or explicit content.<br>\n**Error Code:** `200`<br>\nOnly an account administrator can change a profile pict",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "pic_file",
              "description": "(Required) The file's path. ",
              "type": "file",
              "src": [
              ]
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/users/:userId/picture",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId",
            "picture"
          ],
          "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><br>\n**Error Code:** `1001`<br>\nUser does not exist: $userId.\n",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "pic_file",
              "description": "(Required) The file's path. ",
              "type": "file",
              "src": [
              ]
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/users/:userId/picture",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId",
            "picture"
          ],
          "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": ""
    }
  ]
}