CARVIEW |
Select Language
HTTP/2 301
content-type: text/html; charset=utf-8
location: https://googleapis.github.io/google-api-java-client/batching.html
cache-control: private, max-age=2592000
pragma:
vary: Cookie
vary: Accept-Encoding
content-security-policy: base-uri 'self'; object-src 'none'; script-src 'strict-dynamic' 'unsafe-inline' https: http: 'nonce-sY+JmpErUgfbWdofze7cB1l6eTllrQ' 'unsafe-eval'; frame-ancestors 'self' https://codeassist.google.com https://code-assist-free-tier.corp.google.com; report-uri https://csp.withgoogle.com/csp/devsite/v2
strict-transport-security: max-age=63072000; includeSubdomains; preload
x-xss-protection: 0
x-content-type-options: nosniff
expires: 0
content-encoding: gzip
x-cloud-trace-context: 74c7c0594cad9807f72834878872a87f
date: Wed, 15 Oct 2025 11:54:14 GMT
server: Google Frontend
content-length: 203
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Thu, 02 Oct 2025 03:27:03 GMT
access-control-allow-origin: *
etag: W/"68ddf107-1e76"
expires: Wed, 15 Oct 2025 12:04:14 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: E124:10707E:9442:A77D:68EF8B66
accept-ranges: bytes
age: 0
date: Wed, 15 Oct 2025 11:54:15 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210058-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1760529255.708618,VS0,VE293
vary: Accept-Encoding
x-fastly-request-id: 9b1b8068dee30abf388ca90412faac4be6d44ab2
content-length: 1894
Batching | Google APIs Client Library for Java
Setup Instructions
Component Modules
Android
Google App Engine
Batching
Media Download
Media Upload
OAuth 2.0
Timeouts and Errors
Support
Google APIs Client Library for Java
OverviewSetup Instructions
Component Modules
Android
Google App Engine
Batching
Media Download
Media Upload
OAuth 2.0
Timeouts and Errors
Support
Batching
Each HTTP connection that your client makes results in overhead. To reduce overhead, you can batch multiple API calls together into a single HTTP request.
The main classes of interest are BatchRequest and JsonBatchCallback. The following example shows how to use these classes with service-specific generated libraries:
JsonBatchCallback<Calendar> callback = new JsonBatchCallback<Calendar>() {
public void onSuccess(Calendar calendar, HttpHeaders responseHeaders) {
printCalendar(calendar);
addedCalendarsUsingBatch.add(calendar);
}
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
System.out.println("Error Message: " + e.getMessage());
}
};
...
Calendar client = Calendar.builder(transport, jsonFactory, credential)
.setApplicationName("BatchExample/1.0").build();
BatchRequest batch = client.batch();
Calendar entry1 = new Calendar().setSummary("Calendar for Testing 1");
client.calendars().insert(entry1).queue(batch, callback);
Calendar entry2 = new Calendar().setSummary("Calendar for Testing 2");
client.calendars().insert(entry2).queue(batch, callback);
batch.execute();