Search code examples
google-drive-apigoogle-docs-api

How to add read permission to Google Drive file for multiple users in one request


I'm trying to insert 3 users as readers of a file on Google Drive and Google Docs using the API here https://developers.google.com/drive/v2/reference/permissions/insert

However, this only allows inserting 1 user at a time so I'm currently waiting for the first request to finish before sending the next one.

Is there a way to insert multiple users in one request (using an array to store the users for example)?

I've looked at the /batch endpoint here https://developers.google.com/drive/v2/web/batch, but I'm not sure how to use it or if that's what I need. I want to implement this in jQuery, but the example in the link only shows the request details but not any code.


Solution

  • No, there is no way to add multiple permissions in a single API request. Batching requests still uses multiple API calls but does them all as a single HTTP request. If that is what you want, it's something that the client library has to support.

    You can see an example in Google's client library here: https://developers.google.com/api-client-library/javascript/features/batch