Chilkat Online Tools

SQL Server / Zoom API / Get a user

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, 'UpdateInt', @success OUT, 'login_type', 100
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'encrypted_email', 'true'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'search_by_unique_id', 'true'

    -- 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/:userId', @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)

    -- {
    --   "created_at": "2018-11-15T01:10:08Z",
    --   "custom_attributes": [
    --     {
    --       "key": "cb3674544gexq",
    --       "name": "Country of Citizenship",
    --       "value": "Nepal"
    --     }
    --   ],
    --   "id": "z8dsdsdsdsdCfp8uQ",
    --   "first_name": "Harry",
    --   "last_name": "Grande",
    --   "email": "example@example.com",
    --   "type": 2,
    --   "role_name": "Owner",
    --   "pmi": 100000000,
    --   "use_pmi": false,
    --   "personal_meeting_url": "https://zoom.us/j/6352635623323434343443",
    --   "timezone": "America/Los_Angeles",
    --   "verified": 1,
    --   "dept": "",
    --   "last_login_time": "2019-09-13T21:08:52Z",
    --   "last_client_version": "4.4.55383.0716(android)",
    --   "pic_url": "https://lh4.googleusercontent.com/-hsgfhdgsfghdsfghfd-photo.jpg",
    --   "host_key": "0000",
    --   "jid": "hghghfghdfghdfhgh@xmpp.zoom.us",
    --   "group_ids": [
    --   ],
    --   "im_group_ids": [
    --     "CcSAAAAAAABBBVoQ"
    --   ],
    --   "account_id": "EAAAAAbbbbbCCCCHMA",
    --   "language": "en-US",
    --   "phone_country": "USA",
    --   "phone_number": "15550100",
    --   "status": "active",
    --   "role_id": "hdsfwyteg3675hgfs",
    --   "employee_unique_id": "dddaaaa",
    --   "account_number": 20212021,
    --   "manager": "name@example.com"
    -- }

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

    DECLARE @key nvarchar(4000)

    DECLARE @name nvarchar(4000)

    DECLARE @value nvarchar(4000)

    DECLARE @strVal nvarchar(4000)

    DECLARE @created_at nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'created_at'
    DECLARE @id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
    DECLARE @first_name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @first_name OUT, 'first_name'
    DECLARE @last_name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @last_name OUT, 'last_name'
    DECLARE @email nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @email OUT, 'email'
    DECLARE @v_type int
    EXEC sp_OAMethod @jResp, 'IntOf', @v_type OUT, 'type'
    DECLARE @role_name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @role_name OUT, 'role_name'
    DECLARE @pmi int
    EXEC sp_OAMethod @jResp, 'IntOf', @pmi OUT, 'pmi'
    DECLARE @use_pmi int
    EXEC sp_OAMethod @jResp, 'BoolOf', @use_pmi OUT, 'use_pmi'
    DECLARE @personal_meeting_url nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @personal_meeting_url OUT, 'personal_meeting_url'
    DECLARE @timezone nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @timezone OUT, 'timezone'
    DECLARE @verified int
    EXEC sp_OAMethod @jResp, 'IntOf', @verified OUT, 'verified'
    DECLARE @dept nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @dept OUT, 'dept'
    DECLARE @last_login_time nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @last_login_time OUT, 'last_login_time'
    DECLARE @last_client_version nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @last_client_version OUT, 'last_client_version'
    DECLARE @pic_url nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @pic_url OUT, 'pic_url'
    DECLARE @host_key nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @host_key OUT, 'host_key'
    DECLARE @jid nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @jid OUT, 'jid'
    DECLARE @account_id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @account_id OUT, 'account_id'
    DECLARE @language nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @language OUT, 'language'
    DECLARE @phone_country nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @phone_country OUT, 'phone_country'
    DECLARE @phone_number nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @phone_number OUT, 'phone_number'
    DECLARE @status nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'status'
    DECLARE @role_id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @role_id OUT, 'role_id'
    DECLARE @employee_unique_id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @employee_unique_id OUT, 'employee_unique_id'
    DECLARE @account_number int
    EXEC sp_OAMethod @jResp, 'IntOf', @account_number OUT, 'account_number'
    DECLARE @manager nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @manager OUT, 'manager'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'custom_attributes'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @key OUT, 'custom_attributes[i].key'
        EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'custom_attributes[i].name'
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'custom_attributes[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'group_ids'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'im_group_ids'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'im_group_ids[i]'
        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 "login_type=100"
	-d "encrypted_email=true"
	-d "search_by_unique_id=true"
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/users/:userId

Postman Collection Item JSON

{
  "name": "Get a user",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/users/:userId?login_type=100&encrypted_email=true&search_by_unique_id=true",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "users",
        ":userId"
      ],
      "query": [
        {
          "key": "login_type",
          "value": "100",
          "description": "The user's login method:\n\n`0` — Facebook OAuth</br>`1` — Google OAuth</br>`24` — Apple OAuth</br>`27` — Microsoft OAuth</br>`97` — Mobile device</br>`98` — RingCentral OAuth</br>`99` — API user</br>`100` — Zoom Work email</br>`101` — Single Sign-On (SSO)\n\nThe following login methods are only available in China:\n\n`11` — Phone number</br>`21` — WeChat</br>`23` — Alipay"
        },
        {
          "key": "encrypted_email",
          "value": "true",
          "description": "Whether the email address passed for the `userId` value is an encrypted email address:\n\n* `true` — The email address is encrypted.\n* `false` — The email address is not encrypted.\n\nIf you do not query this parameter, this value defaults to null (`false`)."
        },
        {
          "key": "search_by_unique_id",
          "value": "true",
          "description": "Whether the queried `userId` value is an employee unique ID: \n* `true` — The queried ID is an employee's unique ID. \n* `false` — The queried ID is not an employee's unique ID. \n\nThis value defaults to `false` (null)."
        }
      ],
      "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 view a user's information on a Zoom account. 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**Note:** Users who have not activated their account will have a `pending` status. These users' `created_at` timestamp will also display the time at which the API call was made, **not** the account's creation date. \n\n**Scopes:** `user:read:admin`, `user:read`, `user_info:read` <br> \n* **Note:** The `user_info:read` scope is only available when you pass the `me` value for the `$userId` value. \n\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`"
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200` **OK**<br>\nUser object returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/users/:userId?login_type=100&encrypted_email=true&search_by_unique_id=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId"
          ],
          "query": [
            {
              "key": "login_type",
              "value": "100"
            },
            {
              "key": "encrypted_email",
              "value": "true"
            },
            {
              "key": "search_by_unique_id",
              "value": "true"
            }
          ],
          "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": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"created_at\": \"2018-11-15T01:10:08Z\",\n \"custom_attributes\": [\n  {\n   \"key\": \"cb3674544gexq\",\n   \"name\": \"Country of Citizenship\",\n   \"value\": \"Nepal\"\n  }\n ],\n \"id\": \"z8dsdsdsdsdCfp8uQ\",\n \"first_name\": \"Harry\",\n \"last_name\": \"Grande\",\n \"email\": \"example@example.com\",\n \"type\": 2,\n \"role_name\": \"Owner\",\n \"pmi\": 100000000,\n \"use_pmi\": false,\n \"personal_meeting_url\": \"https://zoom.us/j/6352635623323434343443\",\n \"timezone\": \"America/Los_Angeles\",\n \"verified\": 1,\n \"dept\": \"\",\n \"last_login_time\": \"2019-09-13T21:08:52Z\",\n \"last_client_version\": \"4.4.55383.0716(android)\",\n \"pic_url\": \"https://lh4.googleusercontent.com/-hsgfhdgsfghdsfghfd-photo.jpg\",\n \"host_key\": \"0000\",\n \"jid\": \"hghghfghdfghdfhgh@xmpp.zoom.us\",\n \"group_ids\": [],\n \"im_group_ids\": [\n  \"CcSAAAAAAABBBVoQ\"\n ],\n \"account_id\": \"EAAAAAbbbbbCCCCHMA\",\n \"language\": \"en-US\",\n \"phone_country\": \"USA\",\n \"phone_number\": \"15550100\",\n \"status\": \"active\",\n \"role_id\": \"hdsfwyteg3675hgfs\",\n \"employee_unique_id\": \"dddaaaa\",\n \"account_number\": 20212021,\n \"manager\": \"name@example.com\"\n}"
    },
    {
      "name": "**HTTP Status Code:** `400` **Bad Request**<br>\nBad request<br>\n**Error Code:** `1120`<br>\nA valid invitation to join the Zoom account was not found for this user. <br>\nThis error is thrown if you added a user in your account but the user did not accept t",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/users/:userId?login_type=100&encrypted_email=true&search_by_unique_id=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId"
          ],
          "query": [
            {
              "key": "login_type",
              "value": "100"
            },
            {
              "key": "encrypted_email",
              "value": "true"
            },
            {
              "key": "search_by_unique_id",
              "value": "true"
            }
          ],
          "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": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/users/:userId?login_type=100&encrypted_email=true&search_by_unique_id=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "users",
            ":userId"
          ],
          "query": [
            {
              "key": "login_type",
              "value": "100"
            },
            {
              "key": "encrypted_email",
              "value": "true"
            },
            {
              "key": "search_by_unique_id",
              "value": "true"
            }
          ],
          "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": ""
    }
  ]
}