使用Google Drive API更新权限时出现500错误 [英] Getting 500 Error when using Google Drive API to update permissions

查看:341
本文介绍了使用Google Drive API更新权限时出现500错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图授予任何文件的访问权限时,我收到500错误。当文件与某人共享时,我不想发送电子邮件。我想停止通知电子邮件。

 插入insert = service.permissions()。insert(fileId,newPerm); 
insert.setSendNotificationEmails(false);
newPerm = insert.execute();


500 OK
{
code:500,
errors:[{
domain:global ,
message:内部错误。用户消息:\发生内部错误,导致无法共享这些项目:fileame \,
reason: internalError
}],
message:内部错误。用户消息:\发生内部错误,导致无法共享这些项目:filename \

$ / code>

欣赏任何建议。 解决方案

我开始解决这个问题,但是通过在文件推送和权限插入之间引入暂停来解决问题。


$ b

我的工作流程'(使用http帖子而不是其他客户端):


  1. 推送文件

  2. 获取 fileI d 不符合Google Drive API的响应。 使用 fileId 发送有效内容以插入权限

在步骤3,我总是得到500'内部错误';该文件总是被推送成功。



在我最初的调试中,当我尝试将相同的文件再次推送到Google时,它会返回与之前尝试使用相同文件相同的fileId(因此Google Drive API必须重新识别该文件是相同的)。



但是,当我尝试后续权限插入时(仍在调试)使用相同的fileId,它总是成功的。



因此,我在文件推送之间引入了 20s暂停 和权限插入,这已经完成了技巧(因为时间在我的应用程序中并不重要)。

必须有某种复制延迟(或'time_til_permissions_can_be_inserted')在Google云端硬盘中。很难相信,因为它是谷歌,但嘿。

I am getting 500 error when I am trying to give access permission of any file. I don't want to send e-mail when the file is shared with someone. I want to stop the notification emails.

  Insert insert = service.permissions().insert(fileId, newPerm);
  insert.setSendNotificationEmails(false);
  newPerm = insert.execute();


        500 OK
            {
            "code" : 500,
            "errors" : [ {
            "domain" : "global",
            "message" : "Internal Error. User message: \"An internal                                                     error has occurred which prevented the sharing of these item(s): fileame\"",
           "reason" : "internalError"
            } ],
          "message" : "Internal Error. User message: \"An internal error has occurred which prevented the sharing of these item(s): filename\""
            }

Appreciate any suggestion.

解决方案

I started getting this problem but managed to workaround it by introducing a pause between file push and permission insert.

my 'workflow' (using http posts rather than rest client):

  1. Push file.
  2. Get fileId out of response from Google Drive API.
  3. Send payload to insert permission using fileId

I was always getting the 500 'Internal error' at Step 3; the file was always being pushed successfully.

On my initial debugging, when stepping through, I'd try and push the same file to Google again, and it'd return the same fileId as on previous attempts with the same file (so Google Drive API must recongise the file is the same).

But when I attempted subsequent permission inserts (still debugging) with the same fileId, it was ALWAYS successful.

So I just introduced a 20s pause between file push and permission insert, which has done the trick (as time isn't critical in my application).

There must be some kind of replication delay (or 'time_til_permissions_can_be_inserted') in Google Drive. Hard to believe, seeing as it's Google, but hey.

这篇关于使用Google Drive API更新权限时出现500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆