0

为了检索文件夹的内容,我必须使用以下网址 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

4

1 回答 1

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-01-22T21:40:15.753 回答