10
votes
  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.

1

1 Answers

27
votes

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'