Skip to Content
Technical Articles
Author's profile photo Avinash R

SAP CPI – From Postman to OData as a Receiver iFlow

Introduction:

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.

Prerequisites:

Before we enter into the integration flow, make sure you have the following prerequisites in place:

  1. SAP BTP Account (Trial or Enterprise)
  2. SAP Cloud Platform Integration (CPI)
  3. 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.

Scenario:

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.

Solution:

In the Integration Flow, we are using

  1. HTTPS as a Sender Adapter
  2. Content Modifier to Modify the JSON Data
  3. JSON to XML Converter ( To parse as XML Payload )
  4. Request Reply to connect Receiver End Point.
  5. Receiver as an OData Adapter

Below is my iFlow Design:

 

 

Before testing the iFlow, first we will test the Northwind OData service from POSTMAN.

Get%20Products%20Data%20using%20Postman

Get Products Data using Postman

Status : 200 ok and we get the results of Products Entity.

Now, let’s check the count of the same entityset.

Get%20Products%20Count%20-%20Postman

Get Products Count – Postman

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)

HTTPS%20Sender%20Adapter%20-%20Connection

HTTPS Sender Adapter – Connection

 

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.

Content%20Modifier%20-%20Message%20Body

Content Modifier – Message Body

 

JSON to XML Converter -> To send payload as XML Format.

JSON%20to%20XML%20Converter%20-%20Processing

JSON to XML Converter – Processing

 

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

OData%20Receiver%20Connection

OData Receiver Connection

 

Below is the setup for OData Receiver Processing:

OData%20Receiver%20Processing

OData Receiver Processing

 

Choose Post Method as Operation Details and in the Resource Path, click the Select Button and

  1. Select Local EDMx File option in Connection Source.
  2. POST Method in Operation
  3. Products(In our Case) in Select Entity.
  4. Select All the Fields listed in the screen.
  5. 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.

iFlow%20-%20Endpoint%20URL

iFlow – Endpoint URL

 

ok, Let’s test the Integration Flow from POSTMAN using above URL.

POSTMAN%20-%20Trigger%20the%20iFlow

POSTMAN – Trigger the iFlow

 

Status – 201 Created,¬†yes we have posted one Record in product entity set. Let’s check the data now in OData Service.

POSTMAN%20-%20Fetch%20Records%20to%20Test

POSTMAN – Fetch Records to Test

 

Yes, now our data got posted in the entity set and you can test the count of the same entity set.

 

Conclusion

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.

 

Best Regards,

Avinash

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.