Question

I need to write a very simple script for retrieving the comments added to a file using the file ID, and store the comments to the activesheet I have found this page but I don't really know how to get the code running with an app script.

function retrieveComments(fileId, callback) {
var request = gapi.client.drive.comments.list({
'fileId': fileId
});
request.execute(callback);
}    

Every time I run the code I just get this error:

ReferenceError: "gapi" is not defined. (line 2, file "Comment").

Any help will be highly appreciated!

Was it helpful?

Solution

the short answer:

Drive.Comments.list(id)

the how to:
"Drive" is a call to the drive api but this is still experimental, in your script you need to go in "ressources > advanced google services" and activate the Drive API. You also need to follow the link at the end "These services must also be enabled in the Google Developers Console." and activate the drive API there.

here an example:
you can add a comment to this google document
and then have a look at this script webapp to retrieve all the comments.
the source code of the webapp is here (It's a little mess in there, because I used two differents methods to get the Drvie API to work)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top