Batch Request construction

Query Request construction

A BatchQueryPart is a representation of a single retrieve request. You can use the following methods in order to fill out a request:

BatchQueryPart request = BatchQueryPart.method("GET").uri("$metadata").build();

Note: The valid method value is GET.

ChangeSet construction A BatchChangeSetPart is a representation of a single change request. You can use the following methods in order to fill out a change request:

Map changeSetHeaders = new HashMap();
changeSetHeaders.put("content-type", "application/json;odata=verbose");
BatchChangeSetPart changeRequest = BatchChangeSetPart.method("PUT")
.body("{\"EmployeeName\":\"Frederic Fall MODIFIED\"}")

Note: The valid method values are POST, PUT, DELETE or MERGE.

The change request has to become a part of a changeSet. For that you need to create a changeSet object and to attach the change request to this object.

BatchChangeSet changeSet = BatchChangeSet.newBuilder().build();

Batch request payload construction After you collected all created parts, you can call the method writeBatchRequestBody(..) provided by EntityProvider

List<BatchPart> batchParts = new ArrayList<BatchPart>();
InputStream payload = EntityProvider.writeBatchRequest(batchParts, BOUNDARY);

The second parameter BOUNDARY is necessary information for the construction of the batch request payload. It is the value of the boundary parameter, that is set in Content-Type header of the batch request.

Batch Response interpretation Interpretation of the batch response payload You receive a list of single response by calling EntityProvider.parseBatchResponse(..)

List<BatchSingleResponse> responses = EntityProvider.parseBatchResponse(responseBody, contentType);
for (BatchSingleResponse response : responses) {

Copyright © 2013-2022, The Apache Software Foundation
Apache Olingo, Olingo, Apache, the Apache feather, and the Apache Olingo project logo are trademarks of the Apache Software Foundation.