Title: Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #How to use the Batch Client API in OData V4 ### Construction of OData Client ODataClient odata = ODataClientFactory.getClient(); odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_JSON); ### Construction of a client entity and create request ClientObjectFactory factory = getClient().getObjectFactory(); final ClientEntity entity = factory.newEntity("OData.Demo.Manufacturer"); entity.getProperties().add(factory.newPrimitiveProperty("Name", factory.newPrimitiveValueBuilder().buildString("MyCarManufacturer"))); final URI targetURI = getClient().newURIBuilder(serviceUrl).appendEntitySetSegment("Manufacturers").build(); final ODataEntityCreateRequest createRequest = getClient().getCUDRequestFactory().getEntityCreateRequest(targetURI, entity); ### Add a create request to a changeset BatchManager payloadManager = getClient().getBatchRequestFactory().getBatchRequest(serviceUrl).payloadManager(); final ODataChangeset changeset = payloadManager.addChangeset(); changeset.addRequest(createRequest); ### Construction of a query request final URI targetURI = getClient().newURIBuilder(serviceUrl).appendEntitySetSegment("Manufacturers").appendKeySegment(1).build(); final URI uri = isRelative ? URI.create().relativize(targetURI) : targetURI; ODataEntityRequest queryReq = getClient().getRetrieveRequestFactory().getEntityRequest(uri); queryReq.setAccept(ContentType.APPLICATION_JSON); ### Add query request to payloadManager payload.addRequest(queryReq); ### Fetch the batch response final ODataBatchResponse response = payload.getResponse(); final Iterator responseBodyIter = response.getBody(); final ODataBatchResponseItem changeSetResponse = responseBodyIter.next();