Skip to Content

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

Oct 18, 2017 at 09:00 AM


avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Naina R Oct 18, 2017 at 01:52 PM

hi all

Any idea

10 |10000 characters needed characters left characters exceeded
Atakan Köycü 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="." />


Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

PRADEEP KUMAR Jan 29 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

10 |10000 characters needed characters left characters exceeded