Skip to Content
Technical Articles
Author's profile photo POOJA TIWARI

CPQCPI1-SAP CPI – Calling CPQ REST API in CPI and fetch the data from CPQ.

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.


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 java.util.HashMap;

import groovy.json.*

def Message processData(Message message) {

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


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

json_to_str=”{\”Root\”:{“+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

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Madhukar Govindu
      Madhukar Govindu

      Hello POOJA TIWARI ,

      I need some for important information on SAP CPI Integration with Third Party API.

      (1). Tokopedia  Rest API  integration with SAP CPI suite.

      Short Description :

      This document contains the reference and guideline for Tokopedia Seller API Services.
      This API allows you to integrate your system into Tokopedia. You can manage products, orders, and shops using all API’s that we provided on this document.
      Tokopedia Seller API Services is a JSON-based OAuth2 API.
      All requests must be secure (https) and authenticated.