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
@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
- Create an Apps Script Project (setup OAuth)
- Add Google Drive (v2) library (v3 is not available)
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.