G Suite - Reports API - unable to set doc_type

21 views
Skip to first unread message

urwa shabir

unread,
May 18, 2019, 3:27:56 AM5/18/19
to Google Apps Script Community
Hi,

I am trying to log view history for a Gsuite account in Google sheets.

Here is my code:

function listViews() {
  var userKey = 'all';
  var applicationName = 'drive';
  var optionalArgs = {
    //maxResults: 100,
    eventName: 'view',
    doc_type: 'mp4'
  };
 
  var response = AdminReports.Activities.list(userKey, applicationName, optionalArgs);
  var activities = response.items;
 
  if (activities && activities.length > 0) {
   
    for (i = 0; i < activities.length; i++) {
      var activity = activities[i];
      Logger.log('%s || %s || %s || %s', activity.id.time, activity.actor.email, activity.events[0].parameters[3], activity.events[0].parameters[4]);
    }
  } else {
    Logger.log('No data found.');
  }
}

This still returns all events e.g document, spreadsheet etc i.e. not just mp4.

Can anyone please help out how to set the parameter correctly in the API call.

Related Links:
https://developers.google.com/admin-sdk/reports/v1/reference/activities/list
https://developers.google.com/admin-sdk/reports/v1/appendix/activity/drive?apix_params=%7B%22userKey%22%3A%22all%22%2C%22applicationName%22%3A%22drive%22%2C%22eventName%22%3A%22view%22%2C%22maxResults%22%3A10%7D#view

Thanks.

urwa shabir

unread,
May 18, 2019, 4:11:20 AM5/18/19
to Google Apps Script Community
This fixed it:
...
var optionalArgs = {
    maxResults: 10,
    eventName: 'view',
    filters: 'doc_type==mp4'
  };
....
Reply all
Reply to author
Forward
0 new messages