How to do Batch Request in HCI OData Adaptor
Everyone knows what is OData protocol – It is for accessing diverse data in a common way. With OData adaptor in HCI you can connect any OData service provider and perform the required integration scenario.
In this blog I am explaining how to do a batch request with multiple operations on different OData collections.
If you are new to OData adaptor read this blog: OData Adapter in SAP HANA Cloud Integration
An OData batch request allows you to execute multiple operations in a single HTTP request.
Let’s take an example.
- Assume that you have two OData collections – Products and SalesOrders.
- You should be able to do a batch with multiple operations as given below.
- But, if you are using OData adaptor, you will find that you don’t have an option to choose multiple OData collections as given below.
- It doesn’t mean that HCI is not stopping you from doing a batch request with multiple operations on different OData collections.
- The solution is to send the batch request in the payload irrespective of what you configured in the model operation.
- To show you how it works I have created a simple iFlow. (I am not going to the basics of creating an iflow, if you are new to HCI read this blog)
- I have two OData collections – Products, SalesOrders.
- In my batch request I want to create a Product and a SalesOrder.
- Hence the equivalent batch request payload to be used in HCI content modifier body is given below.
- For your reference the I have attached the body used in the postman rest client, download it here.
- The format of the batch request body to be used is given below. It will be same from all OData services.
- The details for the payload could be taken from the metadata of OData service.
- Given below I have highlighted entitySetName and entityTypeName in my metadata.
- If your backend is an on premise system (ex. SAP Gateway) you need to configure HANA Cloud Connector with your HCI as mentioned in this blog.
- In the adaptor settings the address should be referring to your virtual host and port configured in HCC. And the Proxy Type should be On-Premise.
- Choose a model operation with batch processing enabled. The Odata collection chosen could be independent of the batch payload we are using.
- Now we could deploy the project and see how the two create operations (create product and create salesorder) worked through a batch request.
SAP Technology RIG
Is the XML schema for the batch request standard for all OData service or specific to this example Gateway service?
If we were to use this in a real-life scenario, and the actual payload is generated via Mapping, can the Operation Modeler generate a corresponding XSD file with the appropriate "batch" nodes based on the EDMX definition?
Hello Eng Swee,
In my experience, I haven't seen any other OData service which support batch request.
So I would say its specific to OData g/w service till I find other OData service.
For your second question, yes, Operation modeler generates the nodes.
SAP Technology RIG
Thanks for your blog,
I’ve a same requirement where 2 entity need to post by using batch operation.
With a help of message mapping i need to post Invoice and InvoiceItemDeatils to Odata. and Enabled batch Processing as TRUE by using model operator.
as i flowed your blog, by using below payload i posted successfully to Odata.
bu the issue is,whereas the extracted XSD doesn’t contains the InvoiceItemDetails.
how can we get the XSD from Odata which contains Invoice and InvoiceItemDeatils entity details?
Increase the sub-levels to select the multiple entities in a single batch schema (XSD).