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

      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.





      Author's profile photo David Metser
      David Metser

      Hi Madhukar,

      You are adding a question to an old post that is asking for non related information.

      Your comment was alerted - I closed the alert but i suggest you delete this comment and ask a question instead referencing to this blog post this is how:

      First, please see, as this resource page provides tips for preparing questions that draw responses from our members. Second, feel free to take our Q&A tutorial at, as that will help you when submitting questions to the community.

      Now for some specific suggestions on how you might improve your question:
      * Outline what steps you took to find answers (and why they weren't helpful) -- so members don't make suggestions that you've already tried.
      * Share screenshots of what you've seen/done (if possible), as images always helps our members better understand your problem.
      * Make sure you've applied the appropriate tags -- because if you don't apply the correct tags, the right experts won't see your question to answer it.
      * Use the "insert code" feature when sharing your code, so members have an easier time reading.
      Should you wish, you can revise your question by selecting Actions, then Edit.
      The more details you provide (in questions tagged correctly), the more likely it is that members will be able to respond. As it stands, I don't know if there is enough information here for members to understand your issue. So please consider revising your question because I'd really like to see you get a solution to your problem!
      I hope you find this advice useful, and we're happy to have you as part of SAP Community!

      Author's profile photo Madhukar Govindu
      Madhukar Govindu

      Hello @DavidMetser,

      I am not ab;e to recognize your name in SAP People. The comment I raised regarding the SAP CPI integration with third-party APIs last year. When I was working with SAP CPI Project.



      So right now, I am not working on SAP CPI Project. Just as an integration platform, Which works on Apache Camel internally.



      Thanks & Regards,

      Madhukar. G




      Author's profile photo David Metser
      David Metser

      Hi Madhukar,

      I am part of the community team.

      I was suggesting that you ask a new question following the steps above so the relevant people will answer you...