googleworkspace / googleworkspace/apps-script-samples

[Apps Script - Google Drive v2] The driveId parameter must be specified if and only if corpora is set to drive

Open
#337 4 comments 6 reactions 1 assignee View on GitHub

@vinay-google is already working on this.

Since Jul 5, 2022.

Dominant language
JavaScript
Stars
5.2k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Summary

Getting an error when executing Google Drive (v2) Files.list even if corpora is set to 'drive' and driveId is supplied.

Expected Behavior

Google Drive API v2 Files.list method via Apps Script successfully retrieves files/folders under a Shared Drive when using corpora="drive" and supplying the driveId.

Sample URL:
Description:

Actual Behavior

Google Drive API v2 Files.list method via Apps Script fails with the following error:

Error in Apps Script logs:
Failed with error API call to drive.files.list failed with error: The driveId parameter must be specified if and only if corpora is set to drive.

Steps to Reproduce the Problem

  1. Create an Apps Script Project (setup OAuth)
  2. Add Google Drive (v2) library (v3 is not available)
  3. Copy and execute this function:
function getRetentionFolders() {
   const queryFolder = "trashed=false and mimeType='application/vnd.google-apps.folder'";
   var results = Drive.Files.list({
          corpora: "drive",
          id: <driveId of shared drive>,
          q: queryFolder,
          includeItemsFromAllDrives: true,
          supportsAllDrives: true,
          fields: 'items(kind,id,title,mimeType,createdDate,modifiedDate,parents,driveId)'
   });
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.