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-w7w0DRcVdKWE/yJmEV1M+TSKphB1um' 'unsafe-eval'; frame-ancestors 'self' https://code-assist-free-tier-autopush.corp.google.com https://code-assist-free-tier-staging.corp.google.com https://code-assist-free-tier.corp.google.com https://*.proxy.googlers.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: da82f99666d6a7209920253877f42016
date: Thu, 17 Jul 2025 00:08:39 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: Fri, 23 May 2025 14:25:54 GMT
access-control-allow-origin: *
etag: W/"68308572-1e76"
expires: Thu, 17 Jul 2025 00:18:39 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 3428:398AF5:52B94:53526:68783F06
accept-ranges: bytes
age: 0
date: Thu, 17 Jul 2025 00:08:39 GMT
via: 1.1 varnish
x-served-by: cache-bom4721-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1752710919.318367,VS0,VE298
vary: Accept-Encoding
x-fastly-request-id: 3814d7f055c362759084801117cb08aae94e9b98
content-length: 1896
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();