0
votes

Looking for a way to use the Search Files API to get a particular folder given the share URL of the folder.

Using this reference here for the various search term possibilities: https://developers.google.com/drive/api/v3/reference/query-ref

https://developers.google.com/apis-explorer/#search/drive.files.list/

For the 'q' variable, have tried:

1) mimeType='application/vnd.google-apps.folder' and properties has { key='webViewLink' and value='https://drive.google.com/drive/folders/xyz123'}

returns empty list even though the value does exist

2) mimeType='application/vnd.google-apps.folder'and webViewLink='https://drive.google.com/drive/folders/xyz123'

returns 'Invalid Value' for the 'q' parameter

1

1 Answers

1
votes
  • You want to retrieve files and folders in a folder of https://drive.google.com/drive/folders/xyz123.

If my understanding is correct, how about this answer? You can retrieve the folder ID from the URL of https://drive.google.com/drive/folders/xyz123. In this case, the folder ID is xyz123.

Pattern 1:

When you want to retrieve the files in the folder using the folder ID as follows. Please use it as q.

'### folder ID ###' in parents

Pattern 2:

When you want to retrieve the folders in the folder using the folder ID as follows. Please use it as q.

'### folder ID ###' in parents and mimeType='application/vnd.google-apps.folder'

Note:

  • This query retrieves files under just the folder ID of xyz123. If the folder is nested and you want to retrieve all files with the folder structures, please retrieve recursively it by the script.

Reference:

If this was not the result you want, I apologize.