Google Drive API按名称查询返回无效 [英] Google Drive API Query by Name Returns Invalid

查看:106
本文介绍了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可以正常工作。不知道为什么名称查询不这样做。
  5. 您正在试图使用专门为 Drive v3 API 定义的搜索参数, Drive v2 API



    使用驱动器v2 API ,该文件的名称位于标题下,因此有效的查询为:



    title ='TestDoc'



    鉴于 Drive v3 API ,该文件的名称在'name'下找到:

    name ='TestDoc'


    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.

    解决方案

    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'

    这篇关于Google Drive API按名称查询返回无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆