Get Active Host report request not returning all data

My request to get an active host report (within a 1 day timeframe) isn’t returning all data. I’m using google script editor to store the data in a worksheet.

I’m not receiving an error message. Has anyone come across this issue before?

function getZoomMinutes() {

// Declaring variables
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[2];
var input = sheet.getRange(“A2”);
var cols = sheet.getRange(“A:C”);
var token = getJWT(apiKey, apiSecret);
var user = 0;

// Date variables
var date = new Date();
date.setDate(date.getDate() - 1);
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();

// URL required for API call
var url = ‘https://api.zoom.us/v2/report/users?from=’ + year + ‘-’ + month + ‘-’ + day + ‘T00:00:00Z&to=’ + year + ‘-’ + month + ‘-’ + day + ‘T23:59:59Z&type=active&page_size=300’;

// API parameters
var headers = {
‘Authorization’: ‘Bearer’ + token + ’ ’
};
var params = {
headers: headers
};

// Making API call and parsing JSON response
var response = UrlFetchApp.fetch(url, params);
var zoomData = JSON.parse(response);
var numUsers = zoomData.total_records;

// Clearing existing data
cols.clear();
sheet.getRange(“A1”).setValue(“Email”)
sheet.getRange(“B1”).setValue(“Talk Time”)
sheet.getRange(“C1”).setValue(“Date”)

// Looping through records returned and writing to the Google Sheet
for(user = 0; user < numUsers; user++) {
input.offset(user, 0).setValue(zoomData.users[user].email);
input.offset(user, 1).setValue((zoomData.users[user].meeting_minutes/zoomData.users[user].participants)*zoomData.users[user].meetings);
input.offset(user, 2).setValue(month + “/” + day + “/” + year);
user++;
}

} // END GetZoomMinutes FUNCTION

Hey @aarthur,

Thanks for joining our developer community—I’m happy to take a closer look at this for you!

Is it possible to share the full request URL you’re using (with the variable values included) with me here, as well as what you’re expecting to see in the response but aren’t? This will help me look into it for you.

Thanks!
Will

Hi Will,

Thanks for your help! Here is the full request URL:

https://api.zoom.us/v2/report/users?from=2020-10-19T00:00:00Z&to=2020-10-19T23:59:59Z&type=active&page_size=300

Here’s what the response should be: https://drive.google.com/file/d/1sswR1KR0XLHyubtucNbZTiK9vIfUelFF/view?usp=sharing

And here’s what I’m currently getting: https://drive.google.com/file/d/1D9kY9JH6u-5SPyI-qpW9JvkZ1Lo_fcKZ/view?usp=sharing

I’m getting 131 unique users when I should get 262.

Hi @aarthur,

I see—thank you for providing these details!

I believe that the issue here is a result of the value you’re passing for the to/from fields. This API endpoint supports date, not technically date-time which you appear to be passing:
image

You will need to set the to parameter to at least the next day in order to capture all potential activity.

I hope this helps to clarify, but let me know if you have questions about this.

Thanks,
Will

@will.zoom I tested these changes and there was no difference in the outcome. Each time I run a test, I get exactly half of the number of unique users as is the expected outcome. Does this indicate any particular problem to you?

Hey @aarthur,

Can you share the request/response you get after using date and adding at least a day to your to/from parameters?

Thanks,
Will

@will.zoom Yes, here are those results: https://docs.google.com/spreadsheets/d/1t-vMy0XsmxsBi1EP5b3XUL2hEahgBjNtTqLhDsIfTHs/edit?usp=sharing

I made an adjustment to the code since I last spoke with you and now I’m getting 150 unique users, which is more than before, but still not the amount I should see, 262.

Hi @aarthur,

Thanks for sharing that. Can you add the page_number parameter to your requests and let me know if you’re getting the full results when passing additional page numbers (e.g.,page_number=1, page_number=2,etc.)?

Thanks,
Will

Oh it was my understanding that page number parameters were unnecessary and that the response should include all records on each page. Is that not the case?

Hi @aarthur,

If the number of total records exceeds the page size, you’ll need to page through the results. While this may not necessarily be the case for your request, I did want to rule it out. Let me know if this makes a difference!

Best,
Will

Would you be able to provide or point me toward an example of utilizing pagination in a case like this? I’m hoping to get something more detailed than the Zoom API reference guide for pagination.

Hey @aarthur,

Depending on where your requests are being initiated from this could vary based on framework/language, but generally speaking you will want to have some kind of loop function that follows this kind of pattern:

Request 1:
https://api.zoom.us/v2/report/users?from=2020-10-19T00:00:00Z&to=2020-11-19T23:59:59Z&type=active&page_size=1

Response 1:

{
    "from": "2020-10-19",
    "to": "2020-11-18",
    "page_count": 2,
    "page_number": 1,
    "page_size": 1,
    "total_records": 2,
    "next_page_token": "MUvnrzuUn5yVht6gCPttr36hMR08vgqcxt2",
    "total_meetings": 7,
    "total_participants": 19,
    "total_meeting_minutes": 174,
    "users": [
        {
            "id": "4p4h3VhUQg-9********",
            "email": "someone@example.com",
            "user_name": "someone",
            "type": 2,
            "dept": "",
            "meetings": 1,
            "participants": 2,
            "meeting_minutes": 113,
            "last_client_version": "5.0.24030.0508(mac)",
            "last_login_time": "2020-10-23T16:57:27Z",
            "create_time": "2020-09-01T13:50:37Z"
        }
    ]
}

Grab the next_page_token from response 1, save as a variable to pass as parameter in request 2.

Request 2:
https://api.zoom.us/v2/report/users?from=2020-10-19T00:00:00Z&to=2020-11-19T23:59:59Z&type=active&page_size=1&next_page_token=MUvnrzuUn5yVht6gCPttr36hMR08vgqcxt2

Response 2:

{
    "from": "2020-10-19",
    "to": "2020-11-18",
    "page_size": 1,
    "total_records": 2,
    "next_page_token": "",
    "total_meetings": 7,
    "total_participants": 19,
    "total_meeting_minutes": 174,
    "users": [
        {
            "id": "NXRlnQhwQ********",
            "email": "another_someone@example.com",
            "user_name": "Another someone",
            "type": 2,
            "dept": "60",
            "meetings": 6,
            "participants": 17,
            "meeting_minutes": 61,
            "last_client_version": "5.1.28642.0705(iphone)",
            "last_login_time": "2020-11-16T15:21:09Z",
            "create_time": "2020-03-25T20:11:37Z"
        }
    ]
}

And so on…

I hope this helps!

Best,
Will

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.