In the Shopping Content API, a batch request could have multiple entries, and each entry can be any method (insert, update, delete, or custom) defined on the resource.
Merchant API does not offer custom batch methods. Instead, you can arrange parallel execution of individual requests.
With the client library
If using the client library, consider this Shopping Content API code.
ProductsCustomBatchResponse batchResponse =
content.products().custombatch(batchRequest).execute();
Write the Merchant API equivalent as follows.
List<ApiFuture<ProductInput>> futures;
for (InsertProductInputRequest request : requests) {
futures.add(productInputsServiceClient.insertProductInputCallable().futureCall(request));
}
List<ProductInput> responses;
for (ApiFuture<ProductInput> future : futures) {
responses.add(future.get());
}
Without the client library
If not using the client library, accomplish batching as explained at Batching requests.
For example, consider a Shopping Content API post like the following.
POST https://shoppingcontent.googleapis.com/content/v2.1/products/batch
{
"entries": [
{
"method": "insert",
"product": { … }
} … ]
}
With Merchant API it would be written something like the following.
POST https://merchantapi.googleapis.com/batch
Content-Length: content_length
content-type: multipart/mixed; boundary="================="
--=================
Content-Type: application/http
Content-Transfer-Encoding: binary
POST v1beta/accounts/123/productInputs:insert
Content-Type: application/json
accept: application/json
{...}
--=================
…