Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
pooja_tiwari3
Participant
Introduction –

Since we are aware that SAP CPI does not support OAuth 2.0 with grant-type any other than “Client Credentials”, in this blog we will be learning about fetching bearer token from “grant-type=password” and fetch JWT token from the bearer token and Authenticate a Standard CPQ API.

Design-

In this blog ,we will be creating 2 iflows. 1st for calling standard CPQ API and get the data from CPQ and 2nd iFlow will be called from 1st iFlow to get bearer token and JWT token and authenticate CPQ API in 1st iFlow.

Here We will have 2 blogs explaining each iFlow in details.

iFlow 1-

In this IFlow we are going to use CPQ standard API to get all price-book available in a given Market-Id.

This is standard SAP CPQ API.


Here I am sending payload to iFlow from POSTMAN app and in step 2 I am fetching token from iFlow 2 . In step 3 I am merging the token and input in 1 xml and with series of 3 Content Modifies at step 4 am setting header properties from 2 inputs and header for HTTP method to call CPQ rest API. In step 5 making call to CPQ and fetching the details based on Market-Id passed as query and getting the response back in JSON format and converting that response to XML.

 

In 1st Content Modifier ,we are setting Market-ID received from sender system


In request reply call, we are calling 2nd iFlow to fetch the token ,which we will discuss in 2nd blog:


 

After CM001 we are multicasting the data to request reply and Join/Gather call where we are simply combining the data from source and Token IFlow .

 

In Content Modifier 002, we are setting token received from iflow2.


 

In Content Modifier 003 ,we are creating Bearer token by appending word ”Bearer” before the token value


In Content Modifier 004 ,we are setting header for CPQ REST API call:

 

Here we are setting Authentication and MarketId


In out HTTP receive configuration, we are giving API details along with dynamic MarketId received from sender system:


 

In Next step as we get the response from CPQ, we are adding Root node to JSON before converting it to xml:

 

Here is the script I used:

 

“import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

import groovy.json.*

def Message processData(Message message) {

def jsonOP = message.getBody(String.class);

jsonOP=jsonOP.toString()

def json_to_str=jsonOP.substring(1, jsonOP.length()- 1);

json_to_str="{\"Root\":{"+json_to_str+"}}" ;

message.setBody(json_to_str);

return message;

}”

 

Then using JSON to XML converter:

 

 


 

 

 

And here it completes the iFlow 1 to get the details from CPQ REST API.

Here is the Link for 2nd IFlow here- SAP CPQ REST API Authentication via JWT token in CPI.

 

Please feel free to suggest any changes if you feel is required.

 

Thanks an Regards,

Pooja Tiwari
4 Comments
Labels in this area