代码:尝试使用Google Drive API V2插入新许可时400错误
-
11-12-2019 - |
题
我正在使用Google-API-Client(0.3.0)GEM for My Rails应用程序通过Google Drive API V2访问用户的数据。
我成功按标题搜索了文件,然后尝试使用搜索结果中的文件ID来插入新权限。我想以编程方式允许“任何链接”来评论文件。
在此处遵循示例代码: https://developers.google.com/drive / v2 /引用/权限/插入,我写下了以下代码:
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错误是客户端错误。
修复此错误的任何帮助将非常感谢。
解决方案
在该版本的客户端库中的问题可能是0.3和0.4之间的显着变化。我在当前版本0.4.4上运行了相同的片段,它效果正常。建议更新您的依赖项,如果可能。
不隶属于 StackOverflow