Chilkat Online Tools

SQL Server / Zoom API / List users

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'status', 'active'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'page_size', 30
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'role_id', 'quis officia in reprehenderit'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'page_number', 'quis officia in reprehenderit'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'include_fields', 'custom_attributes'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'next_page_token', 'quis officia in reprehenderit'

    -- Adds the "Authorization: Bearer <access_token>" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.zoom.us/v2/users', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END
    EXEC @hr = sp_OADestroy @resp

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

    -- {
    --   "page_count": 1,
    --   "page_number": 1,
    --   "page_size": 30,
    --   "total_records": 1,
    --   "users": [
    --     {
    --       "id": "z8yAAAAA8bbbQ",
    --       "first_name": "Taylor",
    --       "last_name": "Kim",
    --       "email": "example@example.com",
    --       "type": 2,
    --       "pmi": 111111111,
    --       "timezone": "America/Los_Angeles",
    --       "verified": 1,
    --       "dept": "",
    --       "created_at": "2018-11-15T01:10:08Z",
    --       "last_login_time": "2019-09-13T21:08:52Z",
    --       "last_client_version": "4.4.55383.0716(android)",
    --       "pic_url": "https://example.com/photo.jpg",
    --       "im_group_ids": [
    --         "GroupName"
    --       ],
    --       "status": "active",
    --       "employee_unique_id": "dddaaaa"
    --     }
    --   ]
    -- }

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

    DECLARE @id nvarchar(4000)

    DECLARE @first_name nvarchar(4000)

    DECLARE @last_name nvarchar(4000)

    DECLARE @email nvarchar(4000)

    DECLARE @v_type int

    DECLARE @pmi int

    DECLARE @timezone nvarchar(4000)

    DECLARE @verified int

    DECLARE @dept nvarchar(4000)

    DECLARE @created_at nvarchar(4000)

    DECLARE @last_login_time nvarchar(4000)

    DECLARE @last_client_version nvarchar(4000)

    DECLARE @pic_url nvarchar(4000)

    DECLARE @status nvarchar(4000)

    DECLARE @employee_unique_id nvarchar(4000)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @strVal nvarchar(4000)

    DECLARE @page_count int
    EXEC sp_OAMethod @jResp, 'IntOf', @page_count OUT, 'page_count'
    DECLARE @page_number int
    EXEC sp_OAMethod @jResp, 'IntOf', @page_number OUT, 'page_number'
    DECLARE @page_size int
    EXEC sp_OAMethod @jResp, 'IntOf', @page_size OUT, 'page_size'
    DECLARE @total_records int
    EXEC sp_OAMethod @jResp, 'IntOf', @total_records OUT, 'total_records'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'users'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'users[i].id'
        EXEC sp_OAMethod @jResp, 'StringOf', @first_name OUT, 'users[i].first_name'
        EXEC sp_OAMethod @jResp, 'StringOf', @last_name OUT, 'users[i].last_name'
        EXEC sp_OAMethod @jResp, 'StringOf', @email OUT, 'users[i].email'
        EXEC sp_OAMethod @jResp, 'IntOf', @v_type OUT, 'users[i].type'
        EXEC sp_OAMethod @jResp, 'IntOf', @pmi OUT, 'users[i].pmi'
        EXEC sp_OAMethod @jResp, 'StringOf', @timezone OUT, 'users[i].timezone'
        EXEC sp_OAMethod @jResp, 'IntOf', @verified OUT, 'users[i].verified'
        EXEC sp_OAMethod @jResp, 'StringOf', @dept OUT, 'users[i].dept'
        EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'users[i].created_at'
        EXEC sp_OAMethod @jResp, 'StringOf', @last_login_time OUT, 'users[i].last_login_time'
        EXEC sp_OAMethod @jResp, 'StringOf', @last_client_version OUT, 'users[i].last_client_version'
        EXEC sp_OAMethod @jResp, 'StringOf', @pic_url OUT, 'users[i].pic_url'
        EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'users[i].status'
        EXEC sp_OAMethod @jResp, 'StringOf', @employee_unique_id OUT, 'users[i].employee_unique_id'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'users[i].im_group_ids'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'users[i].im_group_ids[j]'
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

curl -G -d "status=active"
	-d "page_size=30"
	-d "role_id=quis%20officia%20in%20reprehenderit"
	-d "page_number=quis%20officia%20in%20reprehenderit"
	-d "include_fields=custom_attributes"
	-d "next_page_token=quis%20officia%20in%20reprehenderit"
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/users

Postman Collection Item JSON

{
  "name": "List users",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/users?status=active&page_size=30&role_id=quis officia in reprehenderit&page_number=quis officia in reprehenderit&include_fields=custom_attributes&next_page_token=quis officia in reprehenderit",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "users"
      ],
      "query": [
        {
          "key": "status",
          "value": "active",
          "description": "The user's status: \n* `active` — An active user. \n* `inactive` — A deactivated user. \n* `pending` — A pending user.\n\nThis value defaults to `active`."
        },
        {
          "key": "page_size",
          "value": "30",
          "description": "The number of records returned within a single API call."
        },
        {
          "key": "role_id",
          "value": "quis officia in reprehenderit",
          "description": "The role's unique ID. Use this parameter to filter the response by a specific role. You can use the [List Roles](https://marketplace.zoom.us/docs/api-reference/zoom-api/roles/roles) API to get a role's unique ID value."
        },
        {
          "key": "page_number",
          "value": "quis officia in reprehenderit",
          "description": "The page number of the current page in the returned records."
        },
        {
          "key": "include_fields",
          "value": "custom_attributes",
          "description": "Use this parameter to display one of the following attributes in the API call's response: \n* `custom_attributes` — Return the user's custom attributes. \n* `host_key` — Return the user's [host key](https://support.zoom.us/hc/en-us/articles/205172555-Using-your-host-key)."
        },
        {
          "key": "next_page_token",
          "value": "quis officia in reprehenderit",
          "description": "The next page token is used to paginate through large result sets. A next page token will be returned whenever the set of available results exceeds the current page size. The expiration period for this token is 15 minutes."
        }
      ]
    },
    "description": "Use this API to list your account's users. \n\n**Scopes:** `user:read:admin` \n\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`"
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200`<br>\nUser list returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/users?status=active&page_size=30&role_id=quis officia in reprehenderit&page_number=quis officia in reprehenderit&include_fields=custom_attributes&next_page_token=quis officia in reprehenderit",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users"
          ],
          "query": [
            {
              "key": "status",
              "value": "active"
            },
            {
              "key": "page_size",
              "value": "30"
            },
            {
              "key": "role_id",
              "value": "quis officia in reprehenderit"
            },
            {
              "key": "page_number",
              "value": "quis officia in reprehenderit"
            },
            {
              "key": "include_fields",
              "value": "custom_attributes"
            },
            {
              "key": "next_page_token",
              "value": "quis officia in reprehenderit"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"page_count\": 1,\n \"page_number\": 1,\n \"page_size\": 30,\n \"total_records\": 1,\n \"users\": [\n  {\n   \"id\": \"z8yAAAAA8bbbQ\",\n   \"first_name\": \"Taylor\",\n   \"last_name\": \"Kim\",\n   \"email\": \"example@example.com\",\n   \"type\": 2,\n   \"pmi\": 111111111,\n   \"timezone\": \"America/Los_Angeles\",\n   \"verified\": 1,\n   \"dept\": \"\",\n   \"created_at\": \"2018-11-15T01:10:08Z\",\n   \"last_login_time\": \"2019-09-13T21:08:52Z\",\n   \"last_client_version\": \"4.4.55383.0716(android)\",\n   \"pic_url\": \"https://example.com/photo.jpg\",\n   \"im_group_ids\": [\n    \"GroupName\"\n   ],\n   \"status\": \"active\",\n   \"employee_unique_id\": \"dddaaaa\"\n  }\n ]\n}"
    }
  ]
}