Skip to Content

PI REST Adapter – Consuming synchronous RESTful service

This blog is part of a collection of blog entries that shows architectural concepts and configuration of the SAP PI REST Adapter. We also added some sample scenarios to make it easier for you to understand how your scenario can be implemented using the PI REST Adapter.

If you haven’t done so far, best is to start with the very first blog PI Rest Adapter – Don’t be afraid within the blog series covering the concepts of the REST adapter. A complete list of all blog entries can be accessed from here PI REST Adapter – Blog Overview.

The current blog shows you along a sample scenario how to consume a synchronous RESTful service. In the example, the target URL is set dynamically by using variables.


We would like to determine geographic coordinates such as latitude and longitude based on a given address. This conversion is called geocoding. Here, we use Google’s Geocoding API in the following format:<given_address>&sensor=false

The given address is set dynamically, the output format is JSON, and the sensor parameter equals false indicates that my application does not use a sensor to determine the location.

The address data type of my outbound interface simply contains street, city, country, region, and zip code. The particular address elements are used to dynamically set the address in the URL of the RESTful service call.

00 Data Type.png

In the SAP Process Integration Designer perspective of the NetWeaver Developer Studio (NWDS), I have defined an Integration Flow with a SOAP sender channel and a REST receiver adapter, i.e., we expose the RESTful service as a SOAP web service. The format of the incoming request message is XML. The response from the Goecoding API is JSON which is converted to XML and passed back to the SOAP sender.

01 Integration Flow.png

In the following I will focus on the configuration of the receiver adapter of type REST.

Configuring the REST receiver channel

On the Integration Flow double click on the receiver channel, and switch to tab REST URL below the Adapter-Specific settings. Enter the URL Pattern as follows using variables for street, city, country, and the sensor:{street_par}+{city_par}+{country_par}&sensor={boolean}

The address variables street_par, city_par, and country_par are replaced by the respective values in the request XML message. For each address part, I use an xpath expression to parse and read the respective values from the XML message. The boolean variable is replaced by the static value false.

02 REST URL.png

Switch to tab REST Operation. Here, I have set the http operation of my RESTful service equals GET.

03 REST Operation.png

Finally, we need to define the format of the messages of the RESTful service. Switch to tab Data Format. Though I have maintained the format of the request message, the settings for the input message are actually superfluous since we do not provide any payload anyway. All information of the request is provided in the URL as seen above. However, entering the request format in the channel doesn’t harm.

The format of the response is expected to be in JSON, so I choose JSON as data format. Furthermore I need to convert the JSON to XML and hence select the Convert to XML check box.

04 data Format.png

Running the scenario

For testing the scenario, I used soapui. In the figure below you see that I have entered an address as request in XML format. The response contains the geographic coordinates of the given address.

05 SOAP UI.png

I hope this blog was helpful to understand the consumption of RESTful services using the SAP PI REST adapter. If you like to learn more, check out the other blogs in the series, accessible from the main blog PI REST Adapter – Blog Overview.

You must be Logged on to comment or reply to a post.
  • Hi Ivo,

    Can you please clarify my query?In Advantco REST adapter,if want to provide the username and password for the URL, there we have "Enable Custom Request HTTP Headers".

    But in PO REST adapter, where to configure these details.

    I have tried using "Pattern Variable Replacement".But when executing, these details are not considered and it is displaying "401 unauhorised2 error.

    Please let me know if any inputs for my query.



  • Hi Alex,

    I want to add two lines into http headers as you see below. I understand that you said, there will be no possibility of it until March 2015. Am I right?



    • Hi,

      right, custom http headers is planned for 7.31 SP15 which is planned to be shipped in March this year. The sample that you have shown in your screenshot should be supported.


  • Hi Alex,

    I have a requirement to set Cross Origin http headers in the REST adapter. These have to be returned to the calling web app.

    Is this supported too with the coming SP?



  • Hi,

    I developed scenario based this blog, but I am getting below error:


    This is the response JSON format:


    Based on it I had created Response Data type.


    Please help me out in creating Data type for response.

    If structure is wrong.

      • Hi Volha,

        the response is displayed as separate entry in the list of messages in message monitor with sender of response equals receiver of request message and receiver equals sender of request message


    • Hi Nani,

      your challenge is that google's result comes without any namespaces inside the xml. (You can see in the soapUI screenshot above. Or send the ws request directly via browser.) The DT of your result message is manually created. So it uses namespaces by default. In consequence your mapping does not find the root element (as it expects it with NS) => error "cannot create target element".

      Solution: use an external definition for your result message.

      We managed it that way.

      "Dirty" way: use XSLT to add the missing NS



  • Hello, I am trying to use the above scenario and the same fails when the REST Adapter makes the call to Google API.

    The error we get is : HTTP GET call to;sensor=false not successful. HTTP/1.0 400 Bad Request

    The reason for the error is because the REST Adapter seems to make the "&" as "& amp ;" [without spaces] in the HTTP URL Is this a bug on the SP2 version that we are on?



    • I never tried this myself and I am not familiar with the REST Api , so I cannot really say.

      Have you tried it yourself and ran into issues?



  • Thanks for the post, very usefull.

    I developed an interface follow this post and works fine.!

    One issue I have in a new interface,

    In the REST URL I need to construct a URL pattern that have more than 10 variables.

    When I use the "pattern variable replacement" I have only 10 entries...

    How can I add more variables...?




    • Hi Martin,

      when you enable the last variable, a table will become visible where you can enter more variables. Please refer to the documentation for the specific values to put in there for the various settings.



      • Ivo,

        Thanks for the answer.

        I see the table at the end of the ten variable but I have problem with fill this.

        I follow the help documentation at,

        Configuring the Receiver REST Adapter - Advanced Adapter Engine - SAP Library

        But unsuccessfull.

        My URL is like this:


        For the first ten varibles for example put (first variable):

        Pattern variable replacement:

        - Value source: "XPath Expression"

        - Pattern element name: CUIT

        - XPath expression: //CUIT

        And work ok.

        For the 11th variable I fill the table:

        Additional Pattern elements:

        - Variable: IMPORTE

        - Type: XPath

        - Expression: //IMPORTE ( but error) try with /ConsultasAFIP/IMPORTE (but error)

        Error is: "Returning to application. Exception: URL placeholder IMPORTE is not configured, or has an empty value"

        Like it not recognise the variable...

        Any suggestions?




  • Hi everyone,

    Thank you so much, all blogs are very interesting and helpful.

    Currently, I am facing some issues with a Receiver Rest Adapter in SAP PI 7.4 SP 10 using OAuth Authentication with SAML Bearer Assertion. The Web service which I want to consume is a Web Service of Salesforce Company. I have already been reading documentation about Salesforce Web services as well as Rest Adapter, but I have not could do it.  Do you have any sample scenario about that?

    Alexander Bundschuh Ivo Kulms Abdullah Azzouni Blog It Forward - Simona Lincheva

  • Hi Ivo Kulms

    Can you please tell me how to create the inbound interface for receiver REST adapter?

    Do we get any XSD or WSDL for REST API ??

    Or we create the inbound interface with same structure that we have used in the SOAP sender side?



  • Hi,

    Thank you so much for the post.

    I am trying to use the above scenario and I have problems with GET parameters. I configured a receiver REST channel. I use this URL pattern: http://<domain_name>/api/transactions_logs?start_date={start_date_par}&end_date={end_date_par}&paginate={boolean} and I configured all elements start_date_par, end_date_par and boolean.

    It seems like PI call only uses URL http://<domain_name>/api/transactions_logs without any parameter.

    When I try testing the URL from Chrome rest client, the target application gets a perfect hit.

    I tried hardcoding all the variables putting in the URL pattern the value

    http://<domain_name>/api/transactions_logs?start_date=2015-09-10T09:00:00&end_date=2015-09-10T09:00:00&paginate=false with same result.

    Can you help me?

    Can you tellme if there are any monitor where I can check URL and message used for PI?

    Any help will be apreciated

  • Hi Ivo/Alex,

    I am working on SOAP(XI) to REST synchronous scenario. I am facing with JSON to XML conversion while executing the scenario.

    PI is sending the request to REST URL in JSON format. For multiple record PI channel is generating JSON in correct format but when we are sending request with single record PI channel is not generating “[ “ (square bracket) for an array field (Items) as required in JSON format.

    Below is the required JSON format:


    "A": "abc",

    "B": "def",

    "C": TRUE,

    "Items": [


            { "T": "123ASD", "c": false }



    Below is the JSON generated by PI:


    "A": "abc",

    "B": "def",

    "C": TRUE,


            { "T": "123ASD", "c": false }


    Any suggestion on this issue?

    Thanks & Regards,

    Nida Fatima

  • Hi,

    I am facing the following challenge while configuring Receiver REST Adapter. The API I am trying to call requires a content MD5-checksum in the HTTP header

    2015-10-21 10_31_42-https___mws.amazonservices.de_scratchpad_index.html.png

    The content-MD5 is not a part of the URL, so it is not possible to set the parameter via Adapter Specific Attributes.

    Thanks & Regards


    2015-10-21 10_31_42-https___mws.amazonservices.de_scratchpad_index.html.png
  • I am getting the same issue

    can you please help me with this

    <![CDATA[ HTTP GET call to Avenue+New York+USA&sensor=false not successful. HTTP/1.0 400 Bad Request



    2016-01-07 16_49_07-SoapUI 4.6.2.png

    this is my channel configuration

    2016-01-07 16_45_32-Configuration_ Integration Builder (coibmpodaix01_POD_00).png

    2016-01-07 16_46_31-Configuration_ Integration Builder (coibmpodaix01_POD_00).png

    2016-01-07 16_46_54-Configuration_ Integration Builder (coibmpodaix01_POD_00).png

    Thanks a lot for your help

  • Hello Team,

    Thank you very much for this wonderful blog. I have some query from my side.

    i am getting the error as given below Avenue+New York+USA&sensor=false not successful. HTTP/1.0 400 Bad Request

    but the url is successfully working in web browser but getting reply as http/1.0 400 bad request.

    and i am using the below XML structure to send the request

    <?xml version="1.0" encoding="UTF-8"?>

    <ns0:address xmlns:ns0="XYZ">







    please suggest if any of the above details are wrong and is there any necessary to upgrade the patch level ?



  • I have configured a scenario with a REST receiver for consuming a REST Service. My URL looks like that:


    The para1 and para2 are in my request payload. The problem is that these parameters are optional. It is possible that they have no value. And the REST service allows calls like this:


    But I get always an error when I try to call the service via the REST receiver with an empty parameter.

    "MP: exception caught with cause URL placeholder para1 is not configured, or has an empty value"

    In my real scenario I have more than 2 parameters and one or more of them are always empty. Is there a solution for this problem? Otherwise I can't use this for my purpose or I have to find a workaround (combine all parameter in one)

      • Hi Alex,

        I was trying to achieve the same thing like Gil, but in the end figured out that it's impossible to leave any parameter value empty. Even I combined all parameters in one in my Java mapping program. "&" this kind of symbol was encoded by PO, and result went error.

  • Dear All,

    I am new to SAP PI but I developed this scenario. During  testing from SOAP UI I am getting the connection time out error  with message ""/wp-content/uploads/2016/08/err1_1016140.png

    Following error message log in Message monitoring


  • Hello,

    Regarding first image. Do you know where do I get the latest version of NWDS with SAP PI perspective inside?    

    I have been working with SAP PI 7.3 for the last few years, is the scenario configuration the same and it only differs by the Adapter type in the ES Builder?

    Kindly regards,

    Arthur Silva

  • Hi Ivo / Alexander,


    Thanks for the blog series. This has really helped me to be un-afraid of the REST adapter as suggested 🙂


    We are currently on PI 7.4 and I have an option to define Custom HTTP Headers in the Receiver REST Adapter.

    However, I face a challenge:

    The HTTP Headers that i need to pass are the username and password.

    The configuration successfully works when i provide them and the REST call is completed.

    However, the issue is that the Password is visible (unmasked) in the Channel as well as in the message audit log (RESTOUT_HTTP_HEADER - pl see screenshots below)



    Is there any way to mask the password or provide the Authentication Header in another way ?





  • Hello Experts,

    I do have strange issue in Asynchronous Rest sender adapter for integer json type.

    When i am posting data using postman for one integer field, if its length is 4 then the request is successful to SAP PO, but if more than 4 digits we are getting 404 error.

    Data type for that field is maintained as integer and 0.unbounder occurances in SAP PO.

    Can some one help on this scenario please as we are using SAP PO 7.5 single stacks SP09.