ODataClient odata = ODataClientFactory.getClient();
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_JSON);
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<ClientEntity> createRequest = getClient().getCUDRequestFactory().getEntityCreateRequest(targetURI, entity);
BatchManager payloadManager = getClient().getBatchRequestFactory().getBatchRequest(serviceUrl).payloadManager();
final ODataChangeset changeset = payloadManager.addChangeset();
changeset.addRequest(createRequest);
final URI targetURI = getClient().newURIBuilder(serviceUrl).appendEntitySetSegment("Manufacturers").appendKeySegment(1).build();
final URI uri = isRelative ? URI.create(<ServiceUri>).relativize(targetURI) : targetURI;
ODataEntityRequest<ClientEntity> queryReq = getClient().getRetrieveRequestFactory().getEntityRequest(uri);
queryReq.setAccept(ContentType.APPLICATION_JSON);
payload.addRequest(queryReq);
final ODataBatchResponse response = payload.getResponse();
final Iterator<ODataBatchResponseItem> responseBodyIter = response.getBody();
final ODataBatchResponseItem changeSetResponse = responseBodyIter.next();
Copyright © 2013-2023, The Apache Software Foundation
Apache Olingo, Olingo, Apache, the Apache feather, and
the Apache Olingo project logo are trademarks of the Apache Software
Foundation.