Skip to Content
avatar image
Former Member

Rest receiver adapter: How to do 'post' using x-www-form-urlencoded and key value in PI

Dear All

I have Proxy - PI - Rest scenario where I am suppose to send the data in x-www-form-urlencoded format. When using postman i am able to receive response properly but if i use PI i am not able to understand how to accommodate key value in PI ESR and and setting required in receiver rest adapter for encoded as well.

Below is the postman result i got and the key value that i need to use in PI as well.

Kindly help !!



rest-query-sap.jpg (65.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Oct 18, 2017 at 01:52 PM

    hi all

    Any idea

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 12, 2017 at 12:22 PM


    You can use XSLT power for this. Like some OAuth 2.0 token services not accepting query string or payload JSON for values. Try this XSLT code with operational mapping (use dummy message type for result its not important)

    x-www-form-urlencoded is usually means raw text. We can generate with XSLT or JAVA mapping.

    MT_Token_Req -> Your input message type root
    grant_type, username, password -> Your input message xml nodes. 
    Change all for your message type.
    Result should be like this: grant_type=xxxxxx&username=yyyyyy&password=zzzzzz
    <xsl:stylesheet version="1.0" xmlns:xsl="">
    	<xsl:output method="html" omit-xml-declaration="yes"/>
    	<xsl:template match="*[local-name()='MT_Token_Req']">
    		<xsl:for-each select="./*">
    				<xsl:when test="name(.) = 'grant_type'">
    					<xsl:text>grant_type=</xsl:text><xsl:value-of select="." />
    				<xsl:when test="name(.) = 'username'">
    					<xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text><xsl:text>username=</xsl:text><xsl:value-of select="." />
    				<xsl:when test="name(.) = 'password'">
    					<xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text><xsl:text>password=</xsl:text><xsl:value-of select="." />
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you , this worked. I added a MessageTransformBean to change the content type to x-www-form-urlencoded in the rest channel too.

  • avatar image
    Former Member
    Jan 29, 2018 at 09:16 AM

    Hi Litza /Atakan,

    Thanks Atakan, XSLT code is working fine when i used in HTTP_AAE adapter at receiver side in a synchronous scenario. But when i am using that code in rest receiver adapter then getting error XML /Json structure is not valid.

    Could you suggest configuration of rest adapter at receiver side.

    System - SAP PI 7.4 SP10.


    Pradeep Kumar

    Add comment
    10|10000 characters needed characters exceeded

  • May 17, 2018 at 11:44 AM

    Hi Pradeep,

    Are you trying to parse querystring? Something like this? grant_type=xxxxxx&username=yyyyyy&password=zzzzzz

    If i understood correctly; you can use XSLT or JAVA Mapping again. But this time JAVA Mapping will be more usefull. Try to parse with "error handling" on REST adapter; you can get an XML structure from there. After that you can parse querystring from XML Node with using UDF or JAVA Mapping.

    Error handling mapping can be like that;

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_XXX_Res xmlns:ns0="">

    Hope it will help.

    Add comment
    10|10000 characters needed characters exceeded