Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 500 Error when using Google Drive API to update permissions

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.

like image 809
Nikita Purwar Avatar asked May 04 '15 09:05

Nikita Purwar


People also ask

How do I fix 403 user Rate limit exceeded?

Resolve a 403 error: Project rate limit exceededRaise the per-user quota in the Google Cloud project. For more information, request a quota increase. Batch requests to make fewer API calls. Use exponential backoff to retry the request.

How do I fix Error 404 on Google Drive?

Browser troubleshooting step: - Clear the browser cache. - Try accessing the 'Class Drive' folder in Incognito/Private mode. - Try using a different browser.


1 Answers

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.

like image 126
eversMcc Avatar answered Sep 27 '22 22:09

eversMcc