Jeremy B.
Jeremy B.

Reputation: 33

Adding optional query parameters to a Comment Compiler Script that utilizes Google Drive API

The issue is that the Comments.list command using the Drive API only allows for the most recent 20 comments to be extracted from each document. See "pageSize" optional parameter within the below link.

https://developers.google.com/drive/api/v3/reference/comments/list?apix_params=%7B%22fileId%22%3A%221TFUL94BHcBH398TKiK_omkpQSbKBLXmkgKf7Nb3-vXg%22%2C%22pageSize%22%3A100%2C%22fields%22%3A%22*%22%7D

I want to increase the "pageSize" optional parameter to 100 because that number seems to be the max number of comments that can be returned using the script. Basically I need help modifying my script to account for this.

I came accross this limitation when I previously had the the script:

var theFolder = DriveApp.getFolderById('1LDcOUPkGN9AtcZkkNqokQOHeDkt8AI_n');
var files = theFolder.getFiles();
var AllComments = [];

while (files.hasNext()) {
  var file = files.next();
  AllComments.push(Drive.Comments.list(file.getId()).items);
}

The current code that I thought would fix my issue looks like this.

var theFolder = DriveApp.getFolderById('1LDcOUPkGN9AtcZkkNqokQOHeDkt8AI_n');
var files = theFolder.getFiles();
var AllComments = [];

while (files.hasNext()) {
  var file = files.next();
  var pageSize100 = {
    pageSize: 100
  };
  AllComments.push(Drive.Comments.list(file.getId(),pageSize100).items);
}

If the documents in the folder individually contained more that 20 comments, I would expect up to 100 comments from that individual document to be displayed, but instead only the 20 most recent comments are being displayed.

Upvotes: 3

Views: 194

Answers (1)

Tanaike
Tanaike

Reputation: 201388

Drive API of Advanced Google Services uses v2. So how about modifying from pageSize: 100 to maxResults: 100?

At Drive API v3, pageSize is used. But at Drive API v2, please use maxResults.

References:

Upvotes: 2

Related Questions