【问题标题】:how to set search parameter in google-api-ruby-client如何在 google-api-ruby-client 中设置搜索参数
【发布时间】:2013-01-23 05:40:15
【问题描述】:

为了检索文件夹的内容,我必须使用以下网址 https://www.googleapis.com/drive/v2/files?q='root' 所以我认为它应该通过传递一个额外的参数来工作

    @client.execute(
    :api_method => @drive.files.list ,
    :parameters =>{q=> "title='root'" })

但这不起作用

发生错误:{"errors"=>[{"domain"=>"global", "reason"=>"invalid", "message"=>"Invalid Value", "locationType"=>"parameter ", "location"=>"q"}], "code"=>400, "message"=>"无效值"}

当我看到请求 uri 时,这很明显

https://www.googleapis.com/drive/v2/files?q=title%253D%27levelA%27

我的第一次尝试是用户 URI.encode "title='root'" 这也不起作用。 我真的不知道如何保留单引号?

最好, 菲利普

ps:链接到提到的 gem http://rubydoc.info/github/google/google-api-ruby-client/frames

【问题讨论】:

    标签: ruby google-drive-api


    【解决方案1】:

    好的,现在我找到了一个可行的解决方案,尽管它非常麻烦。

    search = CGI.escape("q='root'")
    u.query = search
    u= Addressable::URI.parse "https://www.googleapis.com/drive/v2/files"
    req=Google::APIClient::Request.new(:uri=> u)
    client.execute req
    

    我希望这对某人有所帮助..

    【讨论】:

      猜你喜欢
      • 2013-04-18
      • 2012-07-08
      • 1970-01-01
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      相关资源
      最近更新 更多