Problem with Passing application/x-www-form-urlencoded Data

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with Passing application/x-www-form-urlencoded Data

chanaka777
This post has NOT been accepted by the mailing list yet.
Hi All,

I'm trying to send REST (HTTP POST) request with data which needs to be passed with 'application/x-www-form-urlencoded' content type, through wso2 ESB. But from the end point I get the error response which complains on missing required data. Not sure I'm missing something in the way I send the request.

Following is my template code.

<template name="getAccessToken" xmlns="http://ws.apache.org/ns/synapse">
  <sequence>   
    <payloadFactory media-type="json">
        <format>
            {
               "grant_type":"client_credentials"
            }
        </format>
    </payloadFactory>   
    <property name="messageType" value="application/x-www-form-urlencoded" scope="axis2"/>   
    <call>
      <endpoint>
        <http method="post" uri-template="https://api.sandbox.paypal.com/v1/oauth2/token"/>
      </endpoint>
    </call>   
  </sequence>
</template>

The needed headers I'm passing through the soapUI. And the ESB proxy service just call to this template.

Following is the body of the  response with 400 status code.
{"error":"invalid_request","error_description":"grant_type is a required parameter"}

I'm using ESB version 4.8, Java 7, Windows 7
Appreciate if you could help me to go forward.
Regards !
--
Chanaka Dharmarathna