1

My application makes a series of requests to modify threads. Right now, it's doing it thread by thread, but ideally it would batch the thread ids and make one request. Is it possible to do this?

EDIT:

I found this guide for the gmail api https://developers.google.com/gmail/api/guides/batch. It allows request batching but not doing something like batching atomic units, e.g. if I want to modify a group of threads at once, it seems that I still have to make an individual request for each thread (and then batch them into one multi-part request).

user592419
  • 5,103
  • 9
  • 42
  • 67

1 Answers1

1

You should be able to batch requests for the Gmail API. The easiest way to do this is by using the one of the Gmail API client libraries. The Gmail Java client library, for example, has JavaDoc you can review.

For batch requests using the Java client library, the process involves defining a JsonBatchCallback object, defining a BatchRequest object, loading requests into the batch, and then executing the batch. See the Batch documentation for the Java API client library for an example using Google Calendar you can adapt -- just replace the Calendar client calls with Gmail client calls as needed. You will still need to load each request into the batch object before executing it, if that is what you are asking.

Ryan Roth
  • 1,394
  • 9
  • 15
  • Yes, I found the client library but rolled my own instead. Now running into issues with forming the batch. See http://stackoverflow.com/questions/27650927/how-do-i-batch-send-a-multipart-html-post-with-multiple-urls – user592419 Dec 27 '14 at 18:04
  • These days, in the php library at least, there's an example of how to batch in the source code, under `examples/batch.php` – Captain Hypertext Aug 30 '16 at 15:33