Chilkat Online Tools

SQL Server / Zoom API / Get active/inactive host reports

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, 'type', 'active'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'from', '1989-05-07'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'to', '1989-05-07'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'page_size', 30
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'page_number', 1
    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/report/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)

    -- {
    --   "from": "2019-08-14",
    --   "to": "2019-09-14",
    --   "page_count": 1,
    --   "page_number": 1,
    --   "page_size": 30,
    --   "total_records": 3,
    --   "total_meetings": 2,
    --   "total_participants": 10,
    --   "total_meeting_minutes": 10,
    --   "users": [
    --     {
    --       "id": "BzBAAAAAAAfprg",
    --       "email": "example@example.com",
    --       "user_name": "cbcvbvcbvbc",
    --       "type": 1,
    --       "dept": "",
    --       "meetings": 1,
    --       "participants": 5,
    --       "meeting_minutes": 5,
    --       "last_client_version": "4.4.1242.0623(win)",
    --       "last_login_time": "2019-09-13T16:21:40Z",
    --       "create_time": "2019-09-13T16:20:30Z"
    --     },
    --     {
    --       "id": "0CAAAAA6jxcA",
    --       "email": "example@example.com",
    --       "user_name": "xgdzgdfg",
    --       "type": 1,
    --       "dept": "Business",
    --       "meetings": 0,
    --       "participants": 0,
    --       "meeting_minutes": 0,
    --       "last_client_version": "4.4.1242.0623(win)",
    --       "last_login_time": "2019-07-23T00:28:00Z",
    --       "create_time": "2019-07-23T00:27:34Z"
    --     }
    --   ]
    -- }

    -- 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 @email nvarchar(4000)

    DECLARE @user_name nvarchar(4000)

    DECLARE @v_type int

    DECLARE @dept nvarchar(4000)

    DECLARE @meetings int

    DECLARE @participants int

    DECLARE @meeting_minutes int

    DECLARE @last_client_version nvarchar(4000)

    DECLARE @last_login_time nvarchar(4000)

    DECLARE @create_time nvarchar(4000)

    DECLARE @from nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @from OUT, 'from'
    DECLARE @v_to nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_to OUT, 'to'
    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 @total_meetings int
    EXEC sp_OAMethod @jResp, 'IntOf', @total_meetings OUT, 'total_meetings'
    DECLARE @total_participants int
    EXEC sp_OAMethod @jResp, 'IntOf', @total_participants OUT, 'total_participants'
    DECLARE @total_meeting_minutes int
    EXEC sp_OAMethod @jResp, 'IntOf', @total_meeting_minutes OUT, 'total_meeting_minutes'
    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', @email OUT, 'users[i].email'
        EXEC sp_OAMethod @jResp, 'StringOf', @user_name OUT, 'users[i].user_name'
        EXEC sp_OAMethod @jResp, 'IntOf', @v_type OUT, 'users[i].type'
        EXEC sp_OAMethod @jResp, 'StringOf', @dept OUT, 'users[i].dept'
        EXEC sp_OAMethod @jResp, 'IntOf', @meetings OUT, 'users[i].meetings'
        EXEC sp_OAMethod @jResp, 'IntOf', @participants OUT, 'users[i].participants'
        EXEC sp_OAMethod @jResp, 'IntOf', @meeting_minutes OUT, 'users[i].meeting_minutes'
        EXEC sp_OAMethod @jResp, 'StringOf', @last_client_version OUT, 'users[i].last_client_version'
        EXEC sp_OAMethod @jResp, 'StringOf', @last_login_time OUT, 'users[i].last_login_time'
        EXEC sp_OAMethod @jResp, 'StringOf', @create_time OUT, 'users[i].create_time'
        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 "type=active"
	-d "from=1989-05-07"
	-d "to=1989-05-07"
	-d "page_size=30"
	-d "page_number=1"
	-d "next_page_token=quis%20officia%20in%20reprehenderit"
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/report/users

Postman Collection Item JSON

{
  "name": "Get active/inactive host reports",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/report/users?type=active&from=1989-05-07&to=1989-05-07&page_size=30&page_number=1&next_page_token=quis officia in reprehenderit",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "report",
        "users"
      ],
      "query": [
        {
          "key": "type",
          "value": "active",
          "description": "Active or inactive hosts.<br>`active` - Active hosts. <br>`inactive` - Inactive hosts."
        },
        {
          "key": "from",
          "value": "1989-05-07",
          "description": "(Required) Start date in 'yyyy-mm-dd' format. The date range defined by the \"from\" and \"to\" parameters should only be one month as the report includes only one month worth of data at once."
        },
        {
          "key": "to",
          "value": "1989-05-07",
          "description": "(Required) End date."
        },
        {
          "key": "page_size",
          "value": "30",
          "description": "The number of records returned within a single API call."
        },
        {
          "key": "page_number",
          "value": "1",
          "description": "The page number of the current page in the returned records."
        },
        {
          "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": "A user is considered to be an active host during the month specified in the \"from\" and \"to\" range, if the user has hosted at least one meeting during this period. If the user didn't host any meetings during this period, the user is considered to be inactive.<br>The Active Hosts report displays a list of meetings, participants, and meeting minutes for a specific time range, up to one month. The month should fall within the last six months.<br>The Inactive Hosts report pulls a list of users who were not active during a specific period of time. \nUse this API to retrieve an active or inactive host report for a specified period of time. The time range for the report is limited to a month and the month should fall under the past six months. <br>You can specify the type of report and date range using the query parameters.<br>\n**Scopes:** `report:read:admin`<br>\n \n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy`<br>\n**Prerequisites:**<br>\n* Pro or higher plan."
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200`<br>\nActive or inactive hosts report returned.<br>\nThis is only available for paid account: {accountId}.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/report/users?type=active&from=1989-05-07&to=1989-05-07&page_size=30&page_number=1&next_page_token=quis officia in reprehenderit",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "report",
            "users"
          ],
          "query": [
            {
              "key": "type",
              "value": "active"
            },
            {
              "key": "from",
              "value": "1989-05-07"
            },
            {
              "key": "to",
              "value": "1989-05-07"
            },
            {
              "key": "page_size",
              "value": "30"
            },
            {
              "key": "page_number",
              "value": "1"
            },
            {
              "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 \"from\": \"2019-08-14\",\n \"to\": \"2019-09-14\",\n \"page_count\": 1,\n \"page_number\": 1,\n \"page_size\": 30,\n \"total_records\": 3,\n \"total_meetings\": 2,\n \"total_participants\": 10,\n \"total_meeting_minutes\": 10,\n \"users\": [\n  {\n   \"id\": \"BzBAAAAAAAfprg\",\n   \"email\": \"example@example.com\",\n   \"user_name\": \"cbcvbvcbvbc\",\n   \"type\": 1,\n   \"dept\": \"\",\n   \"meetings\": 1,\n   \"participants\": 5,\n   \"meeting_minutes\": 5,\n   \"last_client_version\": \"4.4.1242.0623(win)\",\n   \"last_login_time\": \"2019-09-13T16:21:40Z\",\n   \"create_time\": \"2019-09-13T16:20:30Z\"\n  },\n  {\n   \"id\": \"0CAAAAA6jxcA\",\n   \"email\": \"example@example.com\",\n   \"user_name\": \"xgdzgdfg\",\n   \"type\": 1,\n   \"dept\": \"Business\",\n   \"meetings\": 0,\n   \"participants\": 0,\n   \"meeting_minutes\": 0,\n   \"last_client_version\": \"4.4.1242.0623(win)\",\n   \"last_login_time\": \"2019-07-23T00:28:00Z\",\n   \"create_time\": \"2019-07-23T00:27:34Z\"\n  }\n ]\n}"
    }
  ]
}