googleworkspace / apps-script-samples

Apps Script samples for Google Workspace products.
https://developers.google.com/apps-script
Apache License 2.0
4.49k stars 1.83k forks source link

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

Open gopena-woolpert opened 2 years ago

gopena-woolpert commented 2 years ago

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)'
    });
    }
estellefr commented 2 years ago

I'm also running into this same issue. Is there an ETA for a fix?

mzvarik commented 9 months ago

Me too... zero clue... search also doesn't work without me specificing the "in parents" parameter which can't search subfolders... tf

UnholyCucumber commented 3 weeks ago

Running into the same issue too