Service call out policy not able to recognise first and last value of request body with request content-type as application/x-www-form-urlencoded.
Example :
content-type: application/x-www-form-urlencoded
Body: client_id=0oa3oxptqqWDPHNas1t7&grant_type=authorization_code&code=Qpq_JKePwfZpuhaQRv5P&client_secret=jjvrJ65blf2Ub1gPu-iutZKRiOhbsFVT5JvH1l3N&redirect_uri=http://localhost:8080/
I am getting error for client_id is required field even though I am passing it.
If I change request with some dummy value as first attribute then its able to get client_id.
Body: dummy=dummy1&client_id=0oa3oxptqqWDPHNas1t7&grant_type=authorization_code&code=Qpq_JKePwfZpuhaQRv5P&client_secret=jjvrJ65blf2Ub1gPu-iutZKRiOhbsFVT5JvH1l3N&redirect_uri=http://localhost:8080/
With above request have first value as dummy then service call out is able to get client_id.
Solved! Go to Solution.
I would suggest using 'FormParams' while sending the values for 'Content-Type: application/x-www-form-urlencoded', also it is good coding practice to not hard code sensitive information such as credentials directly into code.
You can pass the value as below:
<FormParams>
<FormParam name="client_id">{clientId}</FormParam>
<FormParam name="client_secret">{clientSecret}</FormParam>
<FormParam name="grant_type">{grantType}</FormParam>
</FormParams>
I would suggest using 'FormParams' while sending the values for 'Content-Type: application/x-www-form-urlencoded', also it is good coding practice to not hard code sensitive information such as credentials directly into code.
You can pass the value as below:
<FormParams>
<FormParam name="client_id">{clientId}</FormParam>
<FormParam name="client_secret">{clientSecret}</FormParam>
<FormParam name="grant_type">{grantType}</FormParam>
</FormParams>
Hi,
This works for me :
<Set> <Payload contentType="application/x-www-form-urlencoded" variablePrefix="$" variableSuffix="%"><![CDATA[Request Body Here]]> </Payload> <Verb>POST</Verb> </Set>
Thanks for this. CDATA sections FTW.
And also, you don't need the variablePrefix and variableSuffix.
you can do this:
<Set> <Payload contentType="application/x-www-form-urlencoded"> <![CDATA[Request Body Here]]> </Payload> <Verb>POST</Verb> </Set>
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |