Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive API Query by Name Returns Invalid

  1. According to Google Drive documentation, to query for a file by name you would use: q="name = 'file name'".

    https://developers.google.com/drive/v3/web/search-parameters

  2. When I try to search by name here: https://developers.google.com/drive/v2/reference/files/list#try-it

    Setting the "q" field to "name = 'file_name'".

    "The value of the parameter 'q' is invalid." is returned.

  3. The same thing happens when I try to execute the command in Python:\ service.files().list(q="name = 'file_name'").execute()

  4. Other commands like q="trashed=false" work fine. Not sure why "name" queries do not.

like image 996
Christopher Carlson Avatar asked Jan 12 '16 03:01

Christopher Carlson


People also ask

How do I fix Error 403 user limit exceeded?

Resolve a 403 error: Project rate limit exceededRaise the per-user quota in the Google Cloud project. For more information, request a quota increase. Batch requests to make fewer API calls. Use exponential backoff to retry the request.


1 Answers

The issue you are having is that you are attempting to use search parameters defined specifically for the Drive v3 API with the Drive v2 API.

When using the Drive v2 API, the name of the file is found under 'title', so a valid query is:

title = 'TestDoc'

Whereas in Drive v3 API, the name of the file is found under 'name':

name = 'TestDoc'

like image 82
Ryan Roth Avatar answered Oct 09 '22 09:10

Ryan Roth