My backend endpoint is https://targeturl.com/token.oauth2 and it accepts Content-type:application/x-www-form-urlencoded
I should send below Key=Values in the POST Body. How i can i achieve in xslt dp:url call?
grant_type:client_credentials
client_id:7cjhfjsfb58378-48sfffs80--9bde31bc39c0
client_secret:375dasdgs8ea282a-a5ssf2e-47aaf-sfsfa3f
I wrote below code in xslt but i am getting 400 bad request. Please help me.
<xsl:variable name="reqoauth">
<xsl:text>client_id=7cjhfjsfb58378-48sfffs80--9bde31bc39c0</xsl:text> <xsl:text>&client_secret=375dasdgs8ea282a-a5ssf2e-47aaf-sfsfa3f</xsl:text> <xsl:text>&grant_type=client_credentials</xsl:text>
</xsl:variable>
<xsl:variable name="oAuthresponse">
<dp:url-open target="{$OauthEndpoint}" response="responsecode-binary" content-type="application/x-www-form-urlencoded" ssl-proxy="client:OauthClientProfile" http-method="POST" data-type="base64" timeout="10">
<xsl:value-of select="dp:encode(dp:encode($reqoauth,'url'),'base-64')"/>
</dp:url-open>
</xsl:variable>
<xsl:variable name="tokenresp">
<xsl:copy-of select="dp:stringToJSONx(dp:decode(dp:binary-encode($oAuthresponse/result/binary/node()),'base-64'))"/>
</xsl:variable>
When i checked the probe. The request and response are as below
Request:
client_id%3D7cjhfjsfb58378-48sfffs80--9bde31bc39c0%26client_secret%3D375dasdgs8ea282a-a5ssf2e-47aaf-sfsfa3f%26grant_type%3Dclient_credentials.
Response:
- <binary>***BINARY NODE***</binary>
- <responsecode>400</responsecode>
- <reasonphrase>Bad Request</reasonphrase>
#DataPower#Support#SupportMigration