Google Drive API按名称查询返回无效

Chr*_*son 8 google-drive-api

  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'".

    "参数'q'的值无效." 退回.

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

  4. 其他命令如q ="trashed = false"工作正常.不确定为什么"名称"查询不会.

小智 24

您遇到的问题是,你正在尝试使用专为定义的搜索参数,驱动V3 API驱动版API.

使用Drive v2 API时,文件名称位于"title"下,因此有效查询为:

title ='TestDoc'

而在Drive v3 API中,文件的名称位于"name"下:

name ='TestDoc'

  • 真棒!谢谢. (3认同)