我使用了以下类型的Java代码(在AppEngine中)来转移Google云端硬盘中文件的所有权。突然,这开始失败,服务器“500 OK”错误。有什么改变或可能是什么原因?
// first add new owner as "writer"
Permission newPermission= new Permission();
newPermission.setValue(newOwnerEmail);
newPermission.setType("user");
newPermission.setRole("writer");
Insert insert = service.permissions().insert(fileId, newPermission);
newPermission = insert.execute();
// then transfer ownsership
newPermission.setRole("owner");
newPermission.setValue(newOwnerEmail);
Update update = drive.permissions().update(fileId, newPermission.getId(), newPermission);
update.setTransferOwnership(true);
update.execute();
异常消息就像这样,这并不能说明什么......?
500 OK
{
"code" : 500,
"message" : null
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1045)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
etc...
答案 0 :(得分:1)
好的,我找到了解决方案:
1)将Drive API库更新为1.17.0
2)准备所有权转移时,立即将新的所有者权限角色设置为“所有者”。在早期的API版本中,它必须首先是“作家”。
以下是更正后的代码段:
// first add new permission as "owner"
Permission newPermission= new Permission();
newPermission.setValue(newOwnerEmail);
newPermission.setType("user");
newPermission.setRole("owner");
Insert insert = service.permissions().insert(fileId, newPermission);
newPermission = insert.execute();
// then transfer ownsership
newPermission.setValue(newOwnerEmail);
Update update = drive.permissions().update(fileId, newPermission.getId(), newPermission);
update.setTransferOwnership(true);
update.execute();