Google 驱动器 API 按名称查询 Returns 无效

Google Drive API Query by Name Returns Invalid

  1. 根据 Google 驱动器文档,要按名称查询文件,您可以使用:q="name = 'file name'"。

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

  2. 当我在这里尝试按名称搜索时:https://developers.google.com/drive/v2/reference/files/list#try-it

    将 "q" 字段设置为 "name = 'file_name'"。

    返回

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

  3. 当我尝试执行 Python 中的命令时,同样的事情发生了:\ service.files().list(q="name = 'file_name'").execute()

  4. 其他命令如 q="trashed=false" 工作正常。不知道为什么 "name" 查询没有。

您遇到的问题是您正在尝试使用专门为 Drive v3 API with the Drive v2 API 定义的搜索参数。

当使用 Drive v2 API 时,文件名在 'title' 下找到,因此有效的查询是:

标题='TestDoc'

而在 Drive v3 API 中,文件名位于 'name' 下:

姓名='TestDoc'