google-sheetsgoogle-apps-scriptgoogle-drive-apigoogle-docs

What is the GoogleJsonResponseException error when trying to get Drive.comments.list()?


I am looking for the functionality described in this question and it's answers: Export Google Docs comments into Google Sheets, along with highlighted text?

However, when I run this code I get an error on this line:

Drive.Comments.list(docId).items;

GoogleJsonResponseException: API call to drive.comments.list failed with error: The 'fields' parameter is required for this method.

I believe everything is set up just as described in the answers. I'm not sure what 'fields' paramater it's even referring to and can't find documentation related to this issue.


Solution

  • From your error GoogleJsonResponseException: API call to drive.comments.list failed with error: The 'fields' parameter is required for this method. and the current specification, I guessed that the reason for your current issue might be due to that when Drive API is enabled now, Drive API v3 might be enabled instead of Drive API v2. So, please modify the following script you are showing.

    If your version of Drive API is v3, please modify it as follows.

    From:

    Drive.Comments.list(docId).items;
    

    To:

    Drive.Comments.list(docId, { fields: "*" }).comments;
    

    Note:

    References: