SQL Server / Zoom API / Get plan usage
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
-- 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
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.zoom.us/v2/accounts/:accountId/plans/usage', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.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 @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "plan_base": {
-- "type": "monthly",
-- "hosts": 2,
-- "usage": 1
-- },
-- "plan_zoom_rooms": {
-- "type": "zroom_monthly",
-- "hosts": 1,
-- "usage": 0
-- },
-- "plan_webinar": [
-- {
-- "type": "webinar1000",
-- "hosts": 1,
-- "usage": 1
-- }
-- ],
-- "plan_zoom_events": [
-- {
-- "type": "zoomevents500_monthly",
-- "hosts": 1,
-- "usage": 1
-- }
-- ],
-- "plan_large_meeting": [
-- {
-- "type": "large500_monthly",
-- "hosts": 1,
-- "usage": 1
-- }
-- ],
-- "plan_recording": {
-- "free_storage": "3 GB",
-- "free_storage_usage": "0",
-- "plan_storage": "0",
-- "plan_storage_usage": "0",
-- "plan_storage_exceed": "0"
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @v_type nvarchar(4000)
DECLARE @hosts int
DECLARE @usage int
DECLARE @v_Type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'plan_base.type'
DECLARE @Hosts int
EXEC sp_OAMethod @jResp, 'IntOf', @Hosts OUT, 'plan_base.hosts'
DECLARE @Usage int
EXEC sp_OAMethod @jResp, 'IntOf', @Usage OUT, 'plan_base.usage'
DECLARE @plan_zoom_roomsType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @plan_zoom_roomsType OUT, 'plan_zoom_rooms.type'
DECLARE @plan_zoom_roomsHosts int
EXEC sp_OAMethod @jResp, 'IntOf', @plan_zoom_roomsHosts OUT, 'plan_zoom_rooms.hosts'
DECLARE @plan_zoom_roomsUsage int
EXEC sp_OAMethod @jResp, 'IntOf', @plan_zoom_roomsUsage OUT, 'plan_zoom_rooms.usage'
DECLARE @Free_storage nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Free_storage OUT, 'plan_recording.free_storage'
DECLARE @Free_storage_usage nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Free_storage_usage OUT, 'plan_recording.free_storage_usage'
DECLARE @Plan_storage nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Plan_storage OUT, 'plan_recording.plan_storage'
DECLARE @Plan_storage_usage nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Plan_storage_usage OUT, 'plan_recording.plan_storage_usage'
DECLARE @Plan_storage_exceed nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Plan_storage_exceed OUT, 'plan_recording.plan_storage_exceed'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'plan_webinar'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'plan_webinar[i].type'
EXEC sp_OAMethod @jResp, 'IntOf', @hosts OUT, 'plan_webinar[i].hosts'
EXEC sp_OAMethod @jResp, 'IntOf', @usage OUT, 'plan_webinar[i].usage'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'plan_zoom_events'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'plan_zoom_events[i].type'
EXEC sp_OAMethod @jResp, 'IntOf', @hosts OUT, 'plan_zoom_events[i].hosts'
EXEC sp_OAMethod @jResp, 'IntOf', @usage OUT, 'plan_zoom_events[i].usage'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'plan_large_meeting'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'plan_large_meeting[i].type'
EXEC sp_OAMethod @jResp, 'IntOf', @hosts OUT, 'plan_large_meeting[i].hosts'
EXEC sp_OAMethod @jResp, 'IntOf', @usage OUT, 'plan_large_meeting[i].usage'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/accounts/:accountId/plans/usage
Postman Collection Item JSON
{
"name": "Get plan usage",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
"host": [
"{{baseUrl}}"
],
"path": [
"accounts",
":accountId",
"plans",
"usage"
],
"variable": [
{
"key": "accountId"
}
]
},
"description": "Get information on usage of [plans](https://marketplace.zoom.us/docs/api-reference/other-references/plans) of an account. This API supports regular accounts as well as master and sub accounts. To get plan usage of a regular account, use the `account:read:admin` scope and provide “me” as the value of the `accountId` path parameter.To get plan usage of a master account, provide the keyword \"me\" as the value of the `accountId` path parameter and use the `billing:master` scope. To get plan usage of a sub account, provide the actual account Id of the sub account as the value of the `accountId` path parameter and use the `billing:master` scope. \n\n**Prerequisite**:<br>\nAccount type: master account on a paid Pro, Business or Enterprise plan.<br>\n**Scope:** `billing:master` for master and sub accounts. `account:read:admin` for regular Zoom accounts.<br>\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy`"
},
"response": [
{
"name": "**HTTP Status Code:** `200` <br>\nPlan Usage returned.<br>",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
"host": [
"{{baseUrl}}"
],
"path": [
"accounts",
":accountId",
"plans",
"usage"
],
"variable": [
{
"key": "accountId"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"plan_base\": {\n \"type\": \"monthly\",\n \"hosts\": 2,\n \"usage\": 1\n },\n \"plan_zoom_rooms\": {\n \"type\": \"zroom_monthly\",\n \"hosts\": 1,\n \"usage\": 0\n },\n \"plan_webinar\": [\n {\n \"type\": \"webinar1000\",\n \"hosts\": 1,\n \"usage\": 1\n }\n ],\n \"plan_zoom_events\": [\n {\n \"type\": \"zoomevents500_monthly\",\n \"hosts\": 1,\n \"usage\": 1\n }\n ],\n \"plan_large_meeting\": [\n {\n \"type\": \"large500_monthly\",\n \"hosts\": 1,\n \"usage\": 1\n }\n ],\n \"plan_recording\": {\n \"free_storage\": \"3 GB\",\n \"free_storage_usage\": \"0\",\n \"plan_storage\": \"0\",\n \"plan_storage_usage\": \"0\",\n \"plan_storage_exceed\": \"0\"\n }\n}"
},
{
"name": "**HTTP Status Code:** `400` <br>\n**Error Code:** `200` <br>\nOnly available for paid account.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
"host": [
"{{baseUrl}}"
],
"path": [
"accounts",
":accountId",
"plans",
"usage"
],
"variable": [
{
"key": "accountId"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}