SAP CPI – From Postman to OData as a Receiver iFlow
In this blog, we will be using SAP Cloud Platform Integration(CPI) to post some data to OData from Postman as a Sender.
CPI is a robust integration platform that connects various applications and services, enabling seamless data exchange across an enterprise.
Before we enter into the integration flow, make sure you have the following prerequisites in place:
- SAP BTP Account (Trial or Enterprise)
- SAP Cloud Platform Integration (CPI)
- Basic Knowledge in CPI
Note: Make sure to provide all the roles to authorize your user in BTP under the Role section for Integration Suite Access.
The aim of the iFlow is to post some data in SAP using OData as a receiver adapter and HTTPS as a Sender adapter. Here we are going to call the API from POSTMAN as a Sender.
Since we all might know about Northwind OData service available as open source so we are going to consuming the same OData service to post PRODUCTS(Entity) data.
In the Integration Flow, we are using
- HTTPS as a Sender Adapter
- Content Modifier to Modify the JSON Data
- JSON to XML Converter ( To parse as XML Payload )
- Request Reply to connect Receiver End Point.
- Receiver as an OData Adapter
Below is my iFlow Design:
Before testing the iFlow, first we will test the Northwind OData service from POSTMAN.
Status : 200 ok and we get the results of Products Entity.
Now, let’s check the count of the same entityset.
Status : 200 ok and we get the count of Products Entity which is 13 now.
Let’s see the iFlow parts:
HTTPS Adapter -> To Call the CPI as HTTPS Request(We are using Postman to call and pass the data)
Content Modifier -> Why we are using the Content Modifier is to add Product tag(Since OData usually accepts XML as a payload) outside the JSON payload.
JSON to XML Converter -> To send payload as XML Format.
Below is the sample XML format that accepts OData for Post Call in Products Entity Set.
<?xml version="1.0" encoding="UTF-8"?> <Products> <Product> <ID>12</ID> <Name>Earphone</Name> <Description>Test</Description> <ReleaseDate>2023-10-08T00:00:00</ReleaseDate> <DiscontinuedDate></DiscontinuedDate> <Rating>3</Rating> <Price>1900</Price> </Product> </Products>
For the abode XML code you may notice data is passed inside the Products and Product Tag. This is the reason we have added Content Modifier to add Product and in the JSON to XML Converter we are using Products as Name under Processing Tab.
Request reply and ODATA Receiver -> To Post data in OData Service.
Request Reply is used to connect the OData Receiver in Integration Flow.
Below is the OData Receiver Connection details which holds OData URL in the Address field
Below is the setup for OData Receiver Processing:
Choose Post Method as Operation Details and in the Resource Path, click the Select Button and
- Select Local EDMx File option in Connection Source.
- POST Method in Operation
- Products(In our Case) in Select Entity.
- Select All the Fields listed in the screen.
- Generate XML Schema Definite Checkbox is used to generate XSD file to get the XML format for our entity set.(It will be shown in the Resource Tab in the Integration Flow)
After you deploy your iFlow, you can see your End point URL generated in Manage Integration Content Tile which hold all your iFlows.
ok, Let’s test the Integration Flow from POSTMAN using above URL.
Status – 201 Created, yes we have posted one Record in product entity set. Let’s check the data now in OData Service.
Yes, now our data got posted in the entity set and you can test the count of the same entity set.
In this Article, we have achieved how to call SAP OData Service using CPI from POSTMAN.
Please feel free to share and comment if you have any queries.