Skip to Content

Do you look for a way of integrating your SAP PI landscape with other REST services or to publish a REST service yourself using an SAP PI Endpoint?

If yes, then this blog could be of interest for you.

Do you have already had a look at the SAP PI REST Adapter and its configuration and now you feel “a bit overwhelmed” by the amount of settings?

If yes, then this blog is also the right one for you.

We have prepared a collection of blog entries for the REST Adapter that shows architectural concepts and configuration of the SAP PI REST Adapter and explain the internal processing steps. 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.

Let’s get started.

The first Blog in this series is about the REST Adapter concept and its configuration capabilities. It is a good ramp-up start for working with the REST adapter. It is called

PI Rest Adapter – Don’t be afraid

The next blog in the series deals with a simple scenario that shows how to consume a synchronous RESTful service. In the example, the target URL is set dynamically by using variables.

REST Adapter – Consuming synchronous RESTful service

A useful scenario is the next one that shows how to call a SAP function module via PI’s RFC adapter, and expose the same as a RESTful service.

PI REST Adapter – Exposing a function module as RESTful service

If you like to know more about JSON conversion within the REST adapter, take a look here:

PI REST Adapter – JSON to XML conversion

In case of the provisioning of RESTful services using a REST sender adapter, you have full flexibility for defining the endpoint of the service. An example of a dynamic endpoint can be seen here:
PI REST Adapter – Defining a dynamic endpoint

Within the REST adapter we have shipped a set of pre-defined adapter specific atributes that can be used to control the message flow. Furthermore, you have the possibility to define own custom attributes. An example is shown here:

PI REST Adapter – Using dynamic attributes

A new concept in PI which is unique to the REST adapter is that you are able to expose one and the same endpoint for addressing multiple Integration Flows. Besides the dynamic endpoint definition explained above, this gives you one more option in the definition of endpoints and your routing rules.

PI REST Adapter – Same endpoint for multiple Integration Flows

How the full set of CRUD operations can be mapped to the operations of a Service Interface in SAP PI is shown in the following examples.

In previous releases, we were limited to one Quality of Service per channel. So, in PI REST Adapter – Map CRUD operations to Service Interface Operations we stick to the POST, PUT, and DELETE operations which are all of asynchronous mode, and omitting the GET operation which is of synchronous mode.

With 7.31 SP16 / 7.4 SP11, we have introduced a new feature that allows you to dynamically set the Quality of Service either by HTTP operation or interface operation. This way, we are able to expose all operations as a single end point. An enhancement of the scenario is described in PI REST Adapter – Map CRUD operations to Service Interface Operations with dynamic setting of Quality of Service

If you like to learn more about the various options that the REST adapter supports for handling error situations, check out the following blog.

PI REST Adapter – Custom error handling

Some RESTful services require specific http headers. The following blog shows you along a use case how you can add custom http header elements to the receiver REST adapter.

PI REST Adapter – Define custom http header elements

If you like to poll REST APIs, check out this example: PI REST Adapter – Polling a REST API.

Learn how to access Concur travel and expense management solutions via its REST API, particularly focusing on the OAuth authorization at PI REST Adapter – Connect to Concur.

Still not found what you were looking for?

No problem! Just let us know what kind of information is missing and how we can help.

To report this post you need to login first.

71 Comments

You must be Logged on to comment or reply to a post.

  1. Jose Nunes

    Excelent documents, specially the first one – don’t be afraid!

     

    Looking forward to try this… (please SAP, update the AWS trial image to SP14!)

    (0) 
  2. Angelo Damiao

    Hi Ivo! Great info here! Thanks!

     

    We just upgrade our PI to SP14 but no lucky to have the REST adapter available.

    SLD still show SP12 (java stack) and SP14 (abap stack). Any light in here?

     

    Cheers,

    Angelo

    (0) 
    1. Ivo Kulms Post author

      Hi Angelo,

       

      For me this looks like a deployment issue. From the distance I cannot really explain why the SLD still shows SP12 for the Java Stack.

       

      Another possible reason for not seeing the REST Adapter is missing adapter metadata in ESR. Most likely, you have missed to update the adapter metadata in ESR. Open the ESR, and upload the latest software component version SAP BASIS 7.31/7.4.

      See also upgrade and update documentation, chapter 3.5.1.

       

      https://service.sap.com/~sapidb/011000358700000422062013E

       

      Hope that helps (at least a bit),

      ivo

      (0) 
        1. Ivo Kulms Post author

          Hi Angelo,

           

          The adapter runs under the security settings of NetWeaver and so you cannot change authentication security level in the adapter itself.

           

          ivo

          (0) 
  3. Fons van Nuland

    Hello Ivo,

     

    Great overview! Thank you for that.

     

    There is one question I still have. Is the adapter also downported? If so, which PI version is the last supported for the REST adapter?

     

    Best regards,

    Fons

    (0) 
  4. Fons van Nuland

    Hello Ivo,

    I have another question about the difference between REST and OData adapter. Can I use the REST adapter to forward Gateway OData services? Is this possible with the OData adapter? As there is only a Receiver adapter for the OData adapter.

    Can you tell me the difference between the adapters? As OData is also using the REST protocol?

     

    Best regards,

    Fons

    (0) 
    1. Ivo Kulms Post author

      Hello Fons,

       

      I have not worked with the OData Adapter yet, so I cannot say whether your scenario is feasible.

       

      Regards,

      ivo

      (0) 
  5. Edwin Kense

    Hi Ivo,

     

    Nice blog. We have a requirement for sending attachments using json/rest, is that possible?

     

    The request content type should be multipart/form-data. The first part should be of mime type (contenttype) application/json and be named data and the second part should be of content-type application/pdf and be named mainDocument.

     

    best regards,

    Edwin

    (0) 
  6. vk k

    HI Thanks a lot for your blog!

    I have a question for you and everybody else too!

     

    Currently, without this Rest Adapter there is also a solution for RESTFUL communication using SOAP Axis Framework.
    Let us assume, if the PI/PO system (SP14) is installed without this SOAP Axis Framework, will the REST adapter still work ? or there is a dependency that the SOAP Axis Framework should be installed first ? In other words, Is this New REST adapter dependant on the SOAP Axis Framework or independant ?

     

    Regards,

    Vk

    (0) 
  7. vishal javalkar

    Hi Ivo,

     

    Thanks for sharing excellent blog series !!

    Any idea if we can send HTTP 202 instead of HTTP 200 from PI REST Sender Adapter , like we have a similar functionality for SOAP adapter.

     

    Regards,

    Vishal

    (0) 
  8. Vipin Kanchan

    Hi Ivo / Alexander,

     

    Thanks for this excellent series of blogs on the REST adapter.

    We had a requirement for sending specific json objects as arrays even if there was only one value in it. The reason for this is that the 3rd party provider has used a REST design where to keep consistency, they have serialized some objects as arrays only. This causes the server to look for an array for that json object. When we trigger from SAP PI with 2-5 values for that object, SAP PI converts this object into an array and adds the square brackets with the curly brackets to it. When we trigger from SAP PPI with only one value for that object, SAP PI assumes this object to be a single value and hence does not convert it into an array and only sends curly brackets.

     

    Is there a way to indicate to SAP PI REST adapter that a particular object should always be treated as an array and force it to send square and curly brackets even if there is only one value for the object.

    (0) 
          1. Vipin Kanchan

            Hi Alex,

             

            Is the functionality for indicating that an object should always be treated as an array included in the latest SP13 of PI 7.4. This was for forcing PI REST adapter to send square and curly brackets for an object even if there is only one value for the object.

            I tried to access the note for the SP 13 which is mentioned in the PAM (2240919), but it gives me a not released message.

            (0) 
              1. ENRICO BARSALI

                Hello Alexander, if I could not install the latest SP what is the note that fixes the problem related to “send square and curly brackets for an object even if there is only one value for the object”? I cannot see in the collective note nothing directly related to this issue.

                Thanks

                Enrico

                (0) 
  9. Siva Maranani

    I see there are many articles debating SAP PO vs Gateway.

     

    With so many features for SAP PO REST Adapter, why not use SAP PO over Gateway for enabling REST based services

    (0) 
  10. Martín Piattini Velthuis

    Thanks for the post VERY usefull.

    One issue I have,

    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…?

     

    Thanks

    Regards

    Martin

    (0) 
  11. Víctor Daniel Oliva Fernandez

    Thanks for the post!!!
    I have this scenario, the same restful services has two operation. One for the authentication y the another one for get information (dont work the second operation if you didnt call the first operation).

    The authentication operation send back a cookie and with that cookie is possible call the second operation and get the information.

    I know that scenario is possible develop with SOAP Receiver, AXIS Transport Protocol, but this option I didnt find in the communication channel options.

     

    Do you know if this scenario is possible with REST Adapter?

     

    Thanks for your help.

    (1) 
  12. Fabian Engel

    Hello Alexander,

     

    is it possible to set header parameters (in response messages) like “Access-Control-Allow-Origin” in REST-Sender-Adapter to provide CORS mechanism for Webservices ?

     

    Thank you in advance.

    Best regards,

    Fabian Engel

    (0) 
      1. Fabian Engel

        Thanks Alexander! Seems SAP closes functionality gaps really quick! 🙂

         

        According to OSS Note for our case this functionality should be delivered with XI ADAPTER FRAMEWORK 7.40

        SP013

        000000

         

        Nevertheless in SAP Software Download center the latest patch for SAP_XIAF component is from 2015/11/06 SP12 for XI ADAPTER FRAMEWORK 7.40

         

        (0) 
          1. Fabian Engel

            I think there is a missing link source in OSS Note.

             

            Trying to click on the download link for 7.4 SP13 gives below result.

            As well I can’t find the SP for SAP_XIAF Component in Download center.

             

            No deliverable object available due to objects not available for download yet or insufficient authorization of logged on user


            Can you confirm?

            Thank you

            (0) 
  13. Sylvain Maenhout

    Hello,

     

    thank you for this complete blog ! Good job !

     

    I have a question about standardFaultMessage of a Synchronous Service Interface during execution of WS in REST mode. How it works ? How the fault message is filled ?

     

    Thank you, have a good day.

     

    Regards

    (0) 
      1. Praveen Gujjeti

        Hi Alex,

         

        can you please help me with my last question: “Any idea if this is planned in upcoming support packs?”

         

        This will become an important decision by my client to choose SAP PO or some other middleware solution based on NTLMV2 availability in REST adapter

         

         

        Thanks in Advance,

        Praveen Gujjeti

        (0) 
  14. Vipin Kanchan

    Hi Alex,

     

    In one of the comments above it was mentioned that the PI REST adapter did not support MIME attachments for now. Is there a plan to support this in the near future?

    We have a requirement to send an XML file as an application/octet-stream attachment to a RESTful PUT service.

     

    Regards,

    Vipin

    (0) 
  15. Stéphan BLOCH

    Hello,

     

    First, congratulation for your blog, it has helped me a lot !

     

    Second, my question : do there is a way to customize timeout as for SOAP adapter with parameters XI.Timeout / XMBWS.Timeout

     

    Thank you

     

    Regards

    (0) 
  16. Stéphan BLOCH

    Hello,

     

    we have a SOAP<sync>REST scenario, I need to catch the response to send it back to the sender.

     

    What I experiment is to handle “http code” with value “400”. When the flow start there is no error (status seems to be catched) but I can’t see the “Message Content” from Action “Custom Result” even in Logviewer.

     

    What I want to do is to get back the “Message Content” and integrates it into the response part of my service interface sender. I m not sure it is possible with my version, If I have well understand it only possible from the version 7.4 SP13, is that true ?

     

    If my version is efficient to catch the “Message Content” I have not understand how to do (sorry If you already explain it)

     

    Our system : SAP PO 7.4 SP11


     

    Thank you for your help

     

    Regards

    (0) 
  17. Lalo Ivanov

    Hi Alexander,

     

    REST is the adapter I was expecting from SAP AG since quite some time – robust and really feature-rich. Well done to you and your team !

     

    What I can feel, as well, is that due to its mightiness, this adapter will be (mis)used in slightly different cases than pure REST (if there is such thing as “pure” REST) – have seen already usecases for it – JSON parsing instead custom adapter module, URL vs. payload manipulations, etc. …. I can see it now as a superset of the other adapters, hopefully, we will not end up in complete RESTfulness in AAE/CC configurations

     

    Cheers,

    Lalo Ivanov

    (0) 
  18. Kiran Kumar Munugalchetty

    Hi Alexander

     

    A good blog for starters on Rest Adapter. Thank you for that.

     

    We are facing an issue with CORS, thought if you can help us here

     

    We used the PI Rest Adapter and created a service. We would like to use this service for mobile applications, hence the browsers are throwing the below error

     

    Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin is therefore not allowed access.

     

    I have added the Allow Public Access in Channel section of the Sender Adapter and tried with Allow Cross site requests  values – Allow all clients and also Allow Specific clients.

    Still i donot see the response header being added and the same error is being thrown.

     

    Please let me know if there are any other configurations that have to be done

     

    We are on PI 7.4 SP13 for the component SAP_XIAF and others we are on PI 7.4 SP10

     

    Thanks

    Kiran

    (0) 
  19. Piyush Dimri

    Hi Alex,

    Is there any plan in future to come up other OAuth 2.0 flows for rest adapter to connect with SalesForce and MS Dynamic CRM?  PI rest adapter does not provide great flexibility connecting to 3rd party cloud based tools having different authentications and grant types.

    Right now only two kind of authorization flows is being supported by PI rest adapter i.e. SAML and Concur.

    (0) 
  20. Philippe Addor

    Hi all,

    It seem that the REST (sender) adapter is not handling gzip transport compression, even when the http header Content-Encoding: gzip is set.

    This is wrong in my opinion. For example the HTTP adapter is able to handle it and automatically decompresses gzip compressed messages when it receives a call with the mentioned header set.

    Has this not been implemented or are we doing something wrong?

    I even tried to write an adapter module that decompresses the message, but it seems the adapter somehow corrupts the binary data it receives, so that decompression fails (of course we unchecked “Convert to XML” so that the adapter should not try to convert the compressed string – we would do that in the custom module later).

    Thanks,

    Philippe

    (0) 

Leave a Reply