如何在GoogleAPI ruby客户端中设置搜索参数

如何在GoogleAPI ruby客户端中设置搜索参数,ruby,google-drive-api,Ruby,Google Drive Api,为了检索文件夹的内容,我必须使用以下url “根” 所以我认为它应该通过传递一个额外的参数来工作 @client.execute( :api_method => @drive.files.list , :parameters =>{q=> "title='root'" }) 但这是行不通的 出现错误:{“errors”=>[{“domain”=>“global”,“reason”=>“invalid”,“message”=>“invalid Value

为了检索文件夹的内容,我必须使用以下url “根” 所以我认为它应该通过传递一个额外的参数来工作

    @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”=>“invalid Value”}

当我看到请求uri时,这是非常明显的

https://www.googleapis.com/drive/v2/files?q=title%253D%27levelA%27
我的第一次尝试是对用户URI.encode“title='root'”进行编码,这也不起作用。 我真的不知道我怎么能保留单引号

最好的, 菲利浦


p、 美国:一个指向上述gem的链接

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

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
我希望这对某人有帮助