Chilkat Online Tools

unicodeC / Zoom API / Get daily usage report

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW queryParams;
    HCkHttpResponseW resp;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *date;
    int new_users;
    int meetings;
    int participants;
    int meeting_minutes;
    int year;
    int month;
    int i;
    int count_i;

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

    http = CkHttpW_Create();

    queryParams = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateInt(queryParams,L"year",68423085);
    CkJsonObjectW_UpdateInt(queryParams,L"month",68423085);

    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");

    resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://api.zoom.us/v2/report/daily",queryParams);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilderW_Create();
    CkHttpResponseW_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    respStatusCode = CkHttpResponseW_getStatusCode(resp);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpResponseW_header(resp));
        wprintf(L"Failed.\n");
        CkHttpResponseW_Dispose(resp);
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

    CkHttpResponseW_Dispose(resp);

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

    // {
    //   "year": 2019,
    //   "month": 6,
    //   "dates": [
    //     {
    //       "date": "2019-06-01",
    //       "new_users": 3,
    //       "meetings": 10,
    //       "participants": 20,
    //       "meeting_minutes": 100
    //     },
    //     {
    //       "date": "2019-06-02",
    //       "new_users": 0,
    //       "meetings": 20,
    //       "participants": 80,
    //       "meeting_minutes": 200
    //     },
    //     {
    //       "date": "2019-06-03",
    //       "new_users": 10,
    //       "meetings": 35,
    //       "participants": 100,
    //       "meeting_minutes": 380
    //     }
    //   ]
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    year = CkJsonObjectW_IntOf(jResp,L"year");
    month = CkJsonObjectW_IntOf(jResp,L"month");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"dates");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        date = CkJsonObjectW_stringOf(jResp,L"dates[i].date");
        new_users = CkJsonObjectW_IntOf(jResp,L"dates[i].new_users");
        meetings = CkJsonObjectW_IntOf(jResp,L"dates[i].meetings");
        participants = CkJsonObjectW_IntOf(jResp,L"dates[i].participants");
        meeting_minutes = CkJsonObjectW_IntOf(jResp,L"dates[i].meeting_minutes");
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(queryParams);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

curl -G -d "year=68423085"
	-d "month=68423085"
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/report/daily

Postman Collection Item JSON

{
  "name": "Get daily usage report",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/report/daily?year=68423085&month=68423085",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "report",
        "daily"
      ],
      "query": [
        {
          "key": "year",
          "value": "68423085",
          "description": "Year for this report"
        },
        {
          "key": "month",
          "value": "68423085",
          "description": "Month for this report"
        }
      ]
    },
    "description": "Retrieve daily report to access the account-wide usage of Zoom services for each day in a given month. It lists the number of new users, meetings, participants, and meeting minutes.<br>\n**Prerequisites**<br>\n* Pro or higher plan.<br>\n**Scopes:** `report:read:admin`<br>\n \n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy`"
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200`<br>\nDaily report retrieved.<br>\nThis is only available for paid accounts:{accountId}.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/report/daily?year=68423085&month=68423085",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "report",
            "daily"
          ],
          "query": [
            {
              "key": "year",
              "value": "68423085"
            },
            {
              "key": "month",
              "value": "68423085"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"year\": 2019,\n \"month\": 6,\n \"dates\": [\n  {\n   \"date\": \"2019-06-01\",\n   \"new_users\": 3,\n   \"meetings\": 10,\n   \"participants\": 20,\n   \"meeting_minutes\": 100\n  },\n  {\n   \"date\": \"2019-06-02\",\n   \"new_users\": 0,\n   \"meetings\": 20,\n   \"participants\": 80,\n   \"meeting_minutes\": 200\n  },\n  {\n   \"date\": \"2019-06-03\",\n   \"new_users\": 10,\n   \"meetings\": 35,\n   \"participants\": 100,\n   \"meeting_minutes\": 380\n  }\n ]\n}"
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\n**Error Code:** `300`<br> \nDaily report can only be provided for a month that falls within the recent 6 months.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/report/daily?year=68423085&month=68423085",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "report",
            "daily"
          ],
          "query": [
            {
              "key": "year",
              "value": "68423085"
            },
            {
              "key": "month",
              "value": "68423085"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}