Skip to Content
Technical Articles

PI REST Adapter – Using dynamic attributes

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 which kind of dynamic attributes are supported and how you can use them.


Referring to the flight scenario that we have introduced in the previous blogs PI REST Adapter – JSON to XML conversion and PI REST Adapter – Defining a dynamic endpoint, we will do further enhancements by using the dynamic adapter specific message attributes of the REST adapter. If you haven’t done so far, you should first read the previous blogs to make yourself familiar with the scenario. In short, we provide a RESTful service in order to read different kind of flight information. Within PI, the calls are routed to either function modules BAPI_FLIGHT_GETDETAIL or BAPI_FLIGHT_CHECKAVAILABILITY.

In this blog, we would like to introduce a GET variable mode to distinguish between an expert and a default usage of the service. In the expert mode, in addition to the flight details we add the information of the return table of the function modules to the response of the service call.

To recall, this is how the respective Integration Flow looks like:

03_01 Integration Flow - same.png

Configuring the REST sender channel

In the SAP Process Integration Designer perspective of the NetWeaver Developer Studio (NWDS), we open the existing Integration Flow, and double-click on the sender channel of type REST to open the channel editor. Switch to the REST Resources tab below the Adapter-Specific tab. The rest of the settings remain unchanged.

We can use dynamic attributes to store information of the service call which we then can be used to control the message flow. The REST adapter comes with a set of predefined adapter specific message attributes such as resource, service, and id which are commonly used among RESTful services. In addition to the predefined attributes you can also define custom attributes which are then added to the header of the PI message.

First, we would like to define the resource as constant value flights. Add a new dynamic attribute REST Resource (resource) from the Dynamic Attribute drop down menu, select Manual Value as Value Source, and enter flights into the Static Value field.

03_05 Manual value attribute.png

Next, we would like to define two IDs based on the JSON payload, one for the airline identity, and one for the connection number. Add a new dynamic attribute REST ID (id) from the Dynamic Attribute drop down menu, select JSON Content Element from the Value Source drop down menu, and enter the respective JSON Element from the JSON payload, here FlightDetails.AirlineID. Proceed accordingly for the JSON element FlightDetails.ConnID.

03_06 JSON Element attribute.png

Finally, we define a custom attribute called mode. Select — Custom Attribute — from the Dynamic Attribute drop down menu, enter the Custom Attribute Name mode, select GET Variable from the Value Source drop down menu, and enter the GET Variable Name mode. Though I have chosen here the same name, the custom attribute name and the GET variable name do not have to be identical. Note, that you must not add the GET variable to the url pattern, in our example it remains /{service_part}.

03_07 Custom attribute.png

Enhancing the mapping of the response

Based on the mode attribute, we either like to add the return table to the response or not. So, we need to change the message mapping of the response message. Within the mapping, we need to access the dynamic attribute. I have created a user defined function getASMA to read the value of the dynamic attribute which we will use in the mapping:

@LibraryMethod(title=“getASMA”, description=“get adapter specific message attribute”, category=“UDFPool”, type=ExecutionType.SINGLE_VALUE

     public String getASMA (

       @Argument(title=“”) String namespace,

@Argument(title=“”) String attribute,

             Container container)  throws StreamTransformationException{

            Map<String, Object> all = container.getInputHeader().getAll();

            DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

            DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);

            String value = dynConf.get(key);

                          return value;


From the Integration Flow, you can double click on the operation mapping to navigate to the respective message mapping in the ESR. Expand the source and target structure, and define a new field mapping for the node return. The target node return should be created if the attribute mode equals expert. As you can see from the figure below, we first call the user defined function getASMA. As input parameter of the function I pass the key of the attribute, in our case name mode with namespace The output value of the getASMA function is compared with the constant value expert using standard function equalsS. In case of boolean true, the node is created. Below the return node, the child nodes need to be mapped from the respective nodes of the source structure.

03_08 Mapping of mode.png

Running the scenario

For testing the scenario we use the Advanced REST Client Application in the Google Chrome browser. The endpoint URL of your RESTful service starts with http://<host>:<port>/RESTAdapter with host and port of the SAP PI system, followed by what you have defined in the sender channel, here /demo/flight/<service>. Since we have defined a GET variable, we need to add the GET variable to the URL. Let’s stick here to the checkavail service.

First, I call the service with the default mode info. The URL is as follows: http://<host>:<port>/RESTAdapter/demo/flight/checkavail?mode=info

03_09 Chrome browser 2 Request.png

The response is as follows:

03_10 Chrome browser 2 Response.png

Let’s change the date of the flight details intentionally to a flight that does not exist, and call the service with the expert mode. The URL is as follows: http://<host>:<port>/RESTAdapter/demo/flight/checkavail?mode=expert

03_11 Chrome browser 3 Request.png

In the response you can see that the return items have been added.

03_12 Chrome browser 3 Response.png

You can access the dynamic attributes values from the DynamicConfiguration message header. In the message monitor, select the corresponding message, switch to tab Message Content, and open the DynamicConfiguration message header.

03_14 Dynamic Attributes link.png

Here you can see additional attribute values that we have added.

03_15 Dynamic Attributes.png

I hope this blog was helpful to understand the various options that you have to define dynamic attributes within 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 Alexander,

    I have a similar scenario, but I want to add two parameters in my HTTP Header of Rest Sender.

    I am using Synchronous Sender Rest Adapter where I want to add few standard HTTP header values in the response.

    Do I have a standard Adapter module to do so ? Or I would have to write a custom module?

    I need to add these two fields in Response Header sent by Rest Adapter.

    "Access-Control-Allow-Origin" = "*"

    "Access-Control-Allow-Headers" = "Authorization"

    Will an adapter module help me in this case. I have raised it on SCN too , link :

    It would be great if you can provide some insight.



    • Hi Pragya,

      we have lately added custom http header for the receiver channel, unfortunately custom http header for the response is not supported yet. It's in our backlog but we don't have any concrete shipment date yet.


      • Hi Alex,

        Thanks a lot for responding. So you mean that I won't be able to set HTTP headers.

        Also, the value that I want to set is not custom but standard http parameters which are currently not coming.

        The HTTP parameters that I want to add are :

        "Access-Control-Allow-Origin" = "*"

        "Access-Control-Allow-Headers" = "Authorization"

        Thanks Again !!

        • Hi Pragya,

          what I meant with custom is that you have to add them to the http header.

          I also checked the standard modules that we provide, unfortunately we don't have any module that would fit here.

          So, the only option right now would be to create your own adapter module as long as we haven't enhanced the REST adapter with supporting this.


          • Thanks Alex for your valuable inputs.

            I would look out for creating my own adapter module. Just one question if you can help me here. I have been looking to PI JAVA docs but didn't find any suitable class/method to write or set header. I do see get header methods but nothing to set except for set content type.

            Please let me know which class/ interface can I use for to achieve this.

            Thanks in advance.

          • Hi Pragya,

            I'm developing a integration AAE IDOC-->PI --> REST , and I need send in http header 3 custom parameters.


            My PI version is 7.4 SP 9 and the the HTTP Header only is from SP10 , i want to create a custom adapter module, but i have the same problem in dont know the class/method to set a header .

            Please could you tell me how was resolve your issue?

            Thanks and regards

          • Hola Monica,

            Tengo un caso parecido al tuyo (AAE SOAP->PI->REST), y el servicio REST tiene HTTP Header para autenticar. No he conseguido documentación clara al respecto. Lo pudiste solucionar?.

            Agradezco tus comentarios.


  • Hello,

    I have a synchronous scenario with a REST receiver adapter with a response which comes back with a csv as payoad.

    I don't found how to exploit it and how to convert it into a xml message.

    Do you have some advises to do that ?

    Thank you for all readers.

  • Hi,

    How can i use this dynamic attributs in ESR mapping without using NWDS. I'm not able to use GET operation using REST adapter because of mapping error.

    Please advise.



    • Hello,

      I finally found how to do what I want to do :


      However, I have a question, when I set the date like in my example, the first time it works but if I test another time with a different value for the date, the new value is not taken and the first date set is always in memory.

      Someone knows why ?

      My scenario is REST to PROXY in synchronous way.




        I am having the exact same problem:

        Scenario is REST to PROXY. Both REST Resources and GET Variables are working, but keep the same value until I stop/start the channel.

        Also did a search on Google / OSS Notes / Messages but didn’t find anything.

        Have you found a solution ?


        Seems that's the one:

        2258139 - REST sender channel is caching values from HTTP requests

  • Hi Alexander,

    Is there any way to declare the Additional attributes in REST sender as optional? I have configured one channel for 5 operations, all GET. I can define only 10 custom attributes and mark them as optional. I have 11th Get parameter as well that needs to be marked as optional. In below scenario I need to mark filterBy as optional.


      • Hi  Alexander,

        I am working on REST synchronous scenario with GET  operation & the interface is working fine with Rest url – http://host:port/RESTAdapter/xxxxx/xxxxx/12345678.

        For this i define the endpoint as XXXXX/XXXXX & used suitable XI Dynamic  Attribute  in rest sender channel which is working as expected.

        Now what could be the endpoint & required XI Dynamic Attribute for below url in REST sender channel with GET operation.

        Rest url: http://host:port/RESTAdapter/XXXX/XXXXXX/12345678/docs

        Pls help me on this.


          • Oh! Thanks Alex.

            Currently, I'm passing from "outside" parameters via rest interface by setting some default values, in this way the current (mandatory) parameters are always filled. But this is a workaround.

            Do You have any suggestions on how to handle so many (18+) optional parameters?

            Thanks a lot,


          • Hi Alexander,


            I am working on a requirement of reading the x-csrf-token from Response Header of GET request  Could please help me on how to get this done.What channel config or any UDF will be required for extracting response header.

            I am SAP PO7.5 REST SP10




  • Hi Alex,

    We have implemented PI scenario exactly the same way how you explained here, this was working fine when we are on PI 7.4 SP09 (Single Stack) but recently upgraded our system to PI then the dynamic attributes configured in Sender Rest Adapter missing during response message mapping. The scenario is Rest to Rest synchronous. The strange part is this is working fine with REst to RFC synch scenarios where for Rest to Rest synch scenario the dynamic attributes missing after upgrade. Any idea?


  • I am working on REST (sender) synchronous scenario with GET operation (SAP PI 7.4SP13).
    Question is how can I map HTTP method GET to two different message types on the same Endpoint? But I do not want to do this with neither with a HTTP variable nor an URL pattern element...

    Is this possible with current REST sender adapter?

    Examples for a user management requests retrieving user information of all users respectively a single user.

    GET http://host:port/RESTAdapter/api/users
    -> Get all users, I want to get a list of users

    GET http://host:port/RESTAdapter/api/users/{id}
    -> Get a user by ID, I want to get a single user

    How is it possible than to match operation to message types on operation determination tab (REST sender adapter)

    Best Regards,

  • Hello,

    i’m working with a REST receiver channel. In Pattern Variable Replacement i set an Adapter-Specific attribute:

    I use the Pattern Element Name “token” to dynamic set HTTP Header “Authorization”:

    The Header Attribute Name “Token” has been setup using a java mapping UDF.

    I can see it in Dynamic Configuration:

    When i run the scenario i receive URL placeholder token is not configured, or has an empty value

    Where i’m wrong?
    Best regards
    • Hi Andrea,


      I am having same requirement and facing issue with Dynamic config to populate Header Authorization value.

      Can you please share the code how it is achieved ?




  • Hi Alexander,

    I have a REST to Proxy Sync scenario where I wanted to add a parameter in my HTTP response header header of REST sender adapter. I would need to add ( Access-control-allow-origin="*" )

    I saw the earlier comment on someone requesting the same, but looks like this feature is in your backlog. My requirement is driving me to have the same feature provided in HTTP response header. Here I'm using REST sender adapter. Please let  me know if you have a fixed solution on this feature.

    I look forward to hearing from you.

    Thank you!!

  • Hi Alexander,

    I have a proxy to Rest Synchronous Scenario. I need to read the dynamic configuration parameters. System is giving me general mapping error.


    Can you please help me how to read or remove this error.


    Thanks & Regards,

    Akshay Ruia


  • Hi Alexander,

    Can I ask is it possible to define arrays in the GET URL?

    My scenario is REST > SOAP where the SOAP service has a header structure (which could be mapped to URL parameters easily) and then an items array where there could be 1 to n records. 

    Thanks, Peter

  • Hi Alexander,

    Need some guidance from you. In my scenario we have a sync REST <->PI(7.5)<->Proxy where we are posting orders in SAP.

    we need to authenticate the token we receive in the HTTP header 'Authentication ' against a service and if its valid then only we can proceed else we need to send a HTTP 401 message back.

    I was wondering if this is achievable using the dynamic configurations.





  • Hi Alexander,


    Thanks for sharing nice blog.

    Need help form you. My scenario is SAP PO 7.5 to Sales-force using REST adapter with oauth2.0.

    I am  able to send data from SAP PO 7.5 to Sales-force using REST adapter with oauth2.0 including PATCH method.

    But how can i do Bulk API transmission using REST adapter?. Please guide me to achieve  Bulk API data transmission.

    Thanks in advance for your help.

    Best Regards,

    Karunakar A

  • Is it possible to use date functions in XPath? I tried some functions to get current date without success.
    Test results:
    ** MP: exception caught with cause Invalid XPath expression "get-year-from-date (current-date ())"; Message: "javax.xml.transform.TransformerException: could not find function: get-year-from-date"
    ** Invalid XPath expression "current-date ()"; Message: "javax.xml.transform.TransformerException: Could not find function: current-date"
    ** MP: exception caught with cause Invalid XPath expression "date ()"; Message: "javax.xml.transform.TransformerException: could not find function: date"
    ** MP: exception caught with cause Invalid XPath expression "xs: date ()"; Message: " Prefix must resolve to a namespace: xs - Prefix must resolve to a namespace: xs"
  • Is it me or is the following simply not supported:

    • Rest Receiver
    • Operation Rules filled like so (basically asigning GET and POST to variable operation)
      • getDataReq namespace operation GET
      • setDataReq namespace operation POST
    • REST Operation
      • Value Source = Adapter Specific Attribute
      • Adapter Specify Attribute = REST Operation (operation)

    For the live of me I canont get this working. It seems unlike REST URL tab REST Operation Tab will not work on variables but on Adapter Specifc Attributes but they are not filled and I have no clue how to do that or if that is even possible.



    • Hi Jens,

      the operation is automatically stored in the adapter specific attribute operation, you use adapter specific attributes to share values between REST sender and REST receiver adapters, if you need them in a mapping then you need to use a custom function to read the attribute values, see above, if you need to define a new value that you like to use in the REST receiver adapter, you can define and write this in a custom mapping, here is an example code:

      @LibraryMethod(title="writeASMA", description="write adapter specific message attribute", category="UDFPool", type=ExecutionType.SINGLE_VALUE)
      public String writeASMA (
      @Argument(title="") String value,
      @Argument(title="") String namespace,
      @Argument(title="") String attribute,
      Container container) throws StreamTransformationException{
      Map<String, Object> all = container.getInputHeader().getAll();

      DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

      DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);


      return value;


      Also check out my other blogs about REST adapter, or this one explaining the overall concept of the REST adapter:



      • Hi Alex,

        thanks for reaching out. Indeed the described "automatic store to ASMA" was my expected behavoir. However, I cannot get this working and looking into XPI traces, I see a different kinda story. Mabe it's just a bug in my version (PO 7.5 SP13)



        This is Operation Rules

        This is REST Operation

        XPI Inspector Trace

        So it seems "operation" ASMA will be queried by PI but is not filled.

        Please also notice that "resource" as an variable (as well as the variable (not being an ASMA) operation) both have their respective values "GetMetadataAll" and "GET" from Operation Rules tab.

        So again, my guts feeling is that Operation Rules fills in variables alright but does not fil ASMA / Dynamic Configuration.



        • Hi Jens,

          I have never used the operation rules on my own, but from what I understand it helps to map the service interface operation so actually the message type to a variable, and you are right, the operation rules actually write into variables and not ASMAs.

          My understanding is that at the end you like to define the operation based on the service interface operation, so now that we have defined the variable operation, you need to assign this to the http method, this is done on the REST operation tab, there is no option for assigning variables to the methods in the drop down menus but you can define additional operation mappings in the table on the bottom, this would then overwrite the settings that you do above, I think this is the only option that you have although as said above I never tried on my own.

          So, can you try to add a new rule with expression {operation} pointing to the variable that you have defined in the operation rules, actually you need to add a rule for each operation GET, POST, etc, and the expression would always be {operation}.

          If this really works, I think using operation as variable name is not a good choice, and anyway can't you simply set the ASMA operation in each mapping, you map for each service interface operation differently anyway, so you wouldn't need the operation rules.


          • Hi Alex,

            thanks again for the insights / thoughts on this.

            As for the problem at hand, I tried your suggestion, however, to no avail. I changed the variable name from {operation} to {myOp} in order to no interfere with some internals. My "Rest Operation" Tab looked like this then

            XPI Inspector trace however showed that only the value sourec binding element "Interface" which in my case is "Email_In" is checked upon. The variable {myOp} is readily filled but not checked against.

            Maybe I filled in wrong values I "Additional Operation Mapping" table? Documentation for the format seems be sparse.

            However, my guts feeling is, that also the "Additional Operation Mapping" table does not support variables.

            BTW: I also tried the same with value source = Adapter Specific Attribute and Adapter Specifc Attribute = REST Operation (operation) with filled Additional Operation Mapping table just as depicted above. With basically the same (unsatisfying) results.


            As for your other suggestion why not setting an ASMA "operation" in each mapping: Yeah, I'm doing that now as that seems the only working option for my requirement as far as I can see.

            I would however love to see the possibilty to use both variables in "Rest Operation" tab as well as just simply selecting an operation as Binding Element. So where now only "Interface" and "Interface with Namespace" is an option, I'd love to see "Interface With Operation" (e.g. "Email_In.getMetadata" would map to "GET" and "Emai_In.setMetadata" would map to "POST" in my case) as an option.

            Please let me know If I missed something blatantly obvious along the way.




          • Hi Jens,

            I double-checked with development, and actually for your use case you wouldn't need the operation rules, instead on the REST operation tab, select Binding Element as Value Source, and Interface with Namespace as Binding Element, then maintain Namespace and Interface for each operation, e.g., for GET http://..../Common/Mapping/10/dummyRootNode