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-h5BorHj7Lz97bIw9/UYl7SPRBq44pR' '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: 59ed9de1e2c181f7f90d5aae4e99b53d
date: Tue, 15 Jul 2025 21:53:46 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: Tue, 15 Jul 2025 22:03:47 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: A57D:7CD81:12386B:12A1D9:6876CDE9
accept-ranges: bytes
age: 0
date: Tue, 15 Jul 2025 21:53:47 GMT
via: 1.1 varnish
x-served-by: cache-bom4726-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1752616427.014192,VS0,VE299
vary: Accept-Encoding
x-fastly-request-id: c4dc8fab0f8cae556935960498d8d76a54bf38ef
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();