Skip to Content

REST receiver add custom HTTP header

Hi All,

I am getting access token value from UDF - Lookup, I want to add this value to REST receiver custom HTTP header value.

However, as per my understanding, we need to have xml structure from where we can add xpath expression and pass the value.

As this access_token is coming via lookup, I am not having any xpath expression for this.

How can I pass this value to my HTTP header?



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Sep 04, 2017 at 01:32 PM

    Hello Rashmi,

    You may use adapter specific message attribute: from within the UDF, add dynamic attribute and assign it a value of the acquired access token, then in the REST receiver channel, you can make use of it (in the tab 'REST URL', inspect value source option 'Adapter-Specific Attribute'). Note that attribute's namespace shall be '' for REST adapter (refer to the blog for details), and the attribute name used in the communication channel and in the UDF, shall be exactly the same. The rest of configuration in the communication channel in part of adding custom HTTP header will not be different from the option if you would have acquired the value from the message using XPath.



    Add comment
    10|10000 characters needed characters exceeded

    • Hi Rashmi,

      From the message log, I can see many other HTTP headers are not set as well (or not reflected in the log). Can you make a trace (XPI Inspector trace including HTTP trace) of the receiver channel and see if there is any indication of successful processing of the retrieved adapter specific message attribute, as well as setting of other extra HTTP headers that you configured with fixed values?



  • Sep 05, 2017 at 02:37 PM

    Thank you so much Vadim Klimov...

    Restarting PI system fixed this issue....

    However, getting new issue at response mapping.. I am not able to see what SFDC is sending in response...

    Is there any way to log these messages in REST adapter?

    error -

    Server returned code: 20009/05/2017 09:40:56.689InformationProcessing result09/05/2017 09:40:56.769InformationREST call finished09/05/2017 09:40:56.961ErrorTransmitting the message using connection SOAP_http:// failed, due to: Error encountered while executing mapping: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_SFDC_RESTAPI_QUOTE_STATUS_UPSERT_RESP_V1_; Details:; Cannot create target element /Log_Messages/DT_SFDC_QUOTE_STATUS_RESP/item. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD



    Add comment
    10|10000 characters needed characters exceeded

  • Sep 11, 2017 at 07:18 AM

    Hi Rashmi,

    You can test the SFDC REST API using POSTMAN to check the response JSON format.

    Then you can design your structure in SAP PO and convert the JSON response in the REST receiver channel so that your response mapping doesn't fail.


    Ritesh K

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ritesh Kayal,

      I checked response message from SOAPUI, below is the response I am getting -

      { "access_token": "xxxxxxxxxxxxxxxx.b.62jco7n_Juvd",

      "instance_url": "",

      "id": "",

      "token_type": "Bearer",

      "issued_at": "xxxxxxxx",

      "signature": "xxxxxxxxxxxxxxx+zg=" }

      And below is my structure defined in PI -

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



      <id/> <token_type/>




      In rest receiver channel, for response message I have kept format as JSON...

      But below is the error I am getting for response mapping -

      How should I deal with it?