【发布时间】:2012-07-27 05:08:31
【问题描述】:
我正在为我的 Rails 应用程序使用 google-api-client (0.3.0) gem 来通过 Google Drive API v2 访问用户的数据。
我成功按标题搜索文件,然后尝试使用搜索结果中的文件 ID 插入新权限。我想以编程方式允许“知道链接的任何人”对文件发表评论。
按照这里的示例代码:https://developers.google.com/drive/v2/reference/permissions/insert,我编写了以下代码:
new_permission = gDriveApi.permissions.insert.request_schema.new({
'role' => "reader",
'type' => "anyone",
'value' => "",
'additionalRoles' => ["commenter"],
'withLink' => true })
result = client.execute(:api_method => gDriveApi.permissions.insert,
:body_object => new_permission,
:parameters => { 'fileId' => file_id })
我收到 400 错误。这是哈希转储:
--- !ruby/object:Google::APIClient::Schema::Drive::V2::Permission
data:
error:
errors:
- domain: global reason: parseError
message: This API does not support parsing form-encoded input.
code: 400
message: This API does not support parsing form-encoded input.
根据gem源代码中的errors.rb,4xx错误是客户端错误。
任何帮助修复此错误将不胜感激。
【问题讨论】:
-
我不精通 Ruby,但也许您可以记录 HTTP 请求以查看发生了什么。不过,目前它似乎是客户端库中的一个错误,除非有办法将其配置为执行表单编码的帖子与 JSON 帖子
标签: google-drive-api