apps-script-samples
apps-script-samples copied to clipboard
[Apps Script - Google Drive v2] The driveId parameter must be specified if and only if corpora is set to drive
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)'
});
}
I'm also running into this same issue. Is there an ETA for a fix?
Me too... zero clue... search also doesn't work without me specificing the "in parents" parameter which can't search subfolders... tf