Chilkat Online Tools

PowerBuilder / Zoom API / Get plan usage

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_type
integer li_Hosts
integer li_Usage
string ls_V_Type
integer li_Hosts
integer li_Usage
string ls_Plan_zoom_roomsType
integer li_Plan_zoom_roomsHosts
integer li_Plan_zoom_roomsUsage
string ls_Free_storage
string ls_Free_storage_usage
string ls_Plan_storage
string ls_Plan_storage_usage
string ls_Plan_storage_exceed
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://api.zoom.us/v2/accounts/:accountId/plans/usage",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// 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

ls_V_Type = loo_JResp.StringOf("plan_base.type")
li_Hosts = loo_JResp.IntOf("plan_base.hosts")
li_Usage = loo_JResp.IntOf("plan_base.usage")
ls_Plan_zoom_roomsType = loo_JResp.StringOf("plan_zoom_rooms.type")
li_Plan_zoom_roomsHosts = loo_JResp.IntOf("plan_zoom_rooms.hosts")
li_Plan_zoom_roomsUsage = loo_JResp.IntOf("plan_zoom_rooms.usage")
ls_Free_storage = loo_JResp.StringOf("plan_recording.free_storage")
ls_Free_storage_usage = loo_JResp.StringOf("plan_recording.free_storage_usage")
ls_Plan_storage = loo_JResp.StringOf("plan_recording.plan_storage")
ls_Plan_storage_usage = loo_JResp.StringOf("plan_recording.plan_storage_usage")
ls_Plan_storage_exceed = loo_JResp.StringOf("plan_recording.plan_storage_exceed")
i = 0
li_Count_i = loo_JResp.SizeOfArray("plan_webinar")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_type = loo_JResp.StringOf("plan_webinar[i].type")
    li_Hosts = loo_JResp.IntOf("plan_webinar[i].hosts")
    li_Usage = loo_JResp.IntOf("plan_webinar[i].usage")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("plan_zoom_events")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_type = loo_JResp.StringOf("plan_zoom_events[i].type")
    li_Hosts = loo_JResp.IntOf("plan_zoom_events[i].hosts")
    li_Usage = loo_JResp.IntOf("plan_zoom_events[i].usage")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("plan_large_meeting")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_type = loo_JResp.StringOf("plan_large_meeting[i].type")
    li_Hosts = loo_JResp.IntOf("plan_large_meeting[i].hosts")
    li_Usage = loo_JResp.IntOf("plan_large_meeting[i].usage")
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

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": ""
    }
  ]
}