HTTP batch requests, a feature that lets you send multiple API calls in a single HTTP request, is deprecated for the Google Slides API as of July 19, 2021. Requests sent as part of an HTTP batch request will fail after July 19, 2022.
To migrate away from HTTP batch requests, we recommend that you execute the individual requests separately.
Alternative batching methods
If the batch requests you want to make are within a single presentation, you
might be able to use the
presentations.batchUpdate
method instead.
Unlike HTTP batch requests, this batch method counts as a single API call for quota usage, and guarantees all updates in the batch will be applied together atomically.
Migration example
The following code sample shows an HTTP batch request that needs to be updated to individual executions.
C#
// Create a batch to add the requests to:
var batch = new BatchRequest(slidesService);
// Build some regular Slides API requests, but don't execute them yet:
PresentationsResource.GetRequest request1 =
slidesService.Presentations.Get(presentationId1);
PresentationsResource.GetRequest request2 =
slidesService.Presentations.Get(presentationId2);
// Queue up the requests to be executed as part of the batch, providing
// callbacks to run when the requests finish.
batch.Queue<Presentation>(
request1,
(response, error, i, message) => {
if (error != null) {
// Do something in the event of failure:
Console.WriteLine(error);
} else {
// Do something with the result:
Console.WriteLine(response);
}
});
batch.Queue<Presentation>(
request2,
(response, error, i, message) => {
if (error != null) {
// Do something in the event of failure:
Console.WriteLine(error);
} else {
// Do something with the result:
Console.WriteLine(response);
}
});
// Execute all queued requests as a single batch.
await batch.ExecuteAsync();
Java
// Create a batch to add the requests to:
BatchRequest batch = slidesService.batch();
// Build some regular Slides API requests, but don't execute them yet:
Slides.Presentations.Get request1 = slidesService.presentations().get(presentationId1);
Slides.Presentations.Get request2 = slidesService.presentations().get(presentationId2);
// Queue up the requests to be executed as part of the batch, providing
// callbacks to run when the requests finish.
request1.queue(
batch,
new JsonBatchCallback<Presentation>() {
public void onSuccess(Presentation response, HttpHeaders responseHeaders) {
// Do something with the result:
System.out.println(response);
}
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
// Do something in the event of failure:
System.out.println(e);
}
});
request2.queue(
batch,
new JsonBatchCallback<Presentation>() {
public void onSuccess(Presentation response, HttpHeaders responseHeaders) {
// Do something with the result:
System.out.println(response);
}
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
// Do something in the event of failure:
System.out.println(e);
}
});
// Execute all queued requests as a single batch.
batch.execute();
Python
# Create a batch to add the requests to:
batch = slidesService.new_batch_http_request()
# Build some regular Slides API requests, but don't execute them yet:
request1 = slidesService.presentations().get(presentationId=presentation_id1)
request2 = slidesService.presentations().get(presentationId=presentation_id2)
# Queue up the requests to be executed as part of the batch, providing
# callbacks to run when the requests finish.
def callback(request_id, response, exception):
if exception is not None:
pprint(exception)
else:
pprint(response)
batch.add(request1, callback)
batch.add(request2, callback)
# Execute all the queued requests as a single batch.
batch.execute()
Ruby
# Create a batch to run requests in.
slidesService.batch do |batch|
# Queue up requests to be run as part of the batch. The block will be
# executed when the request completes.
batch.get_presentation(presentation_id1) do |res, err|
if err != nil then
puts "#{err}"
else
puts res.to_json
end
end
batch.get_presentation(presentation_id2) do |res, err|
if err != nil then
puts "#{err}"
else
puts res.to_json
end
end
# All batch requests queued as part of the block will be executed
# automatically.
The following code sample shows the previously batched requests as individual executions.
C#
PresentationsResource.GetRequest request1 =
slidesService.Presentations.Get(presentationId1);
try {
Presentation response = await request1.ExecuteAsync();
// Do something with the result:
Console.WriteLine(response);
} catch (GoogleApiException error) {
// Do something in the event of failure:
Console.WriteLine(response);
}
PresentationsResource.GetRequest request2 =
slidesService.Presentations.Get(presentationId2);
request2.ValueInputOption =
PresentationsResource.GetRequest.ValueInputOptionEnum.RAW;
try {
Presentation response = await request2.ExecuteAsync();
// Do something with the result:
Console.WriteLine(response);
} catch (GoogleApiException error) {
// Do something in the event of failure:
Console.WriteLine(response);
}
Java
Slides.Presentations.Get request1 = slidesService.presentations().get(presentationId1);
try {
Presentation response = request1.execute();
// Do something with the result:
System.out.println(response);
} catch (IOException e) {
// Do something in the event of failure:
System.out.println(e);
}
Slides.Presentations.Get request2 = slidesService.presentations().get(presentationId2);
try {
Presentation response = request2.execute();
// Do something with the result:
System.out.println(response);
} catch (IOException e) {
// Do something in the event of failure:
System.out.println(e);
}
Python
# Build some regular Slides API requests, but don't execute them yet:
request1 = slidesService.presentations().get(presentationId=presentation_id1)
try:
response = request1.execute()
# Do something with the result:
pprint(response)
except HttpError as exception:
# Do something in the event of failure:
pprint(exception)
request2 = slidesService.presentations().get(presentationId=presentation_id2)
try:
response = request2.execute()
# Do something with the result:
pprint(response)
except HttpError as exception:
# Do something in the event of failure:
pprint(exception)
Ruby
slidesService.get_presentation(presentation_id1, range1, request_body1) do |res, err|
if err != nil then
puts "#{err}"
else
puts res.to_json
end
end
slidesService.get_presentation(presentation_id2) do |res, err|
if err != nil then
puts "#{err}"
else
puts res.to_json
end