How to make $batch POST request using Olingo v4 and Java?

424 Views Asked by At

We've to implement batch request for odata in java.I'm new to odata,from the below 2 following references,which one has to be followed.Do we've to construct a batch request or will it be done using odata batch api's?Can anyone please help on how to proceed with the implementation?

https://olingo.apache.org/doc/odata4/tutorials/batch/tutorial_batch.html https://olingo.apache.org/doc/odata4/tutorials/od4_basic_batch_client.html

1

There are 1 best solutions below

0
Shiva On

The batch request will be created automatically by the OData Client.

TLDR;

A batch request is a REST call to a special endpoint $batch, with a well-defined payload type.

The payload consists of batch requests and subtype of chagesets. Both of them are used to club multiple requests into one except the requests in one changeset is expected to be atomic. So, either all the requests execute or in case one or more fails there should be a rollback (or similar) to prevent the others from persisting

https://olingo.apache.org/doc/odata4/tutorials/od4_basic_batch_client.html

This link has the example for creating the client, Then create an entity and set some properties, put it in change set and execute. In the background it will send a batch request as per the OData $batch format as documented in

https://olingo.apache.org/doc/odata4/tutorials/batch/tutorial_batch.html