3

So, for instance, I am executing multiple requests like this

for (final ParentReference previousParent : previousParents) {
    driveService.parents().delete(fileResourceId, previousParent.getId()).execute();
}

Is there a way to execute them in a batch (I mean not like adding to a Collection and then calling execute on each element)?

If there is, will the batch request form some kind of single request to reduce number of API calls and server requests?

I've seen there is a BatchRequest class, but I can't figure if that's what I need and how to use it assuming I have access to com.google.api.services.drive.Drive service.

The BatchRequest takes two arguments and I can't seem to find how to even build it properly, if that's what I need in first place.

1 Answer 1

4

Yes, using a BatchRequest will allow you to perform multiple API requests within a simple HTTP request. More information on how to use batching in the Google APIs Java client library is available here: https://code.google.com/p/google-api-java-client/wiki/Batch

Sign up to request clarification or add additional context in comments.

1 Comment

Your comment helped me to find example but I'll paste direct link to docs so others don't have to search for it: googleapis.github.io/google-api-java-client/batching.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.