Sending Content-Type application/x-www-form-urlencoded WSO2 ESB
<p>I have been working in a service chaining that answers me with a Bearer Token using in WSO2 EMM.
I made a proxy in ESB and then I passed to a new sequence that makes the next call but this one receives a Content-Type application/x-www-form-urlencoded. I have been looking for some help so that I can find anything interesting.</p>

<p>This is my proxy </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;proxy name="TokenService" startOnLoad="true" statistics="enable"
  trace="enable" transports="http https" xmlns="http://ws.apache.org/ns/synapse"&gt;
  &lt;target&gt;
    &lt;inSequence&gt;
      &lt;!--Aggregate incoming responses --&gt;
      &lt;log level="full"&gt;
        &lt;property name="sequence" value="Paso 1 - request for client register"/&gt;
      &lt;/log&gt;
      &lt;property description="Content-Type" name="ContentType"
        scope="default" type="STRING" value="application/json"/&gt;
      &lt;header name="Accept" scope="transport" value="application/json"/&gt;
      &lt;payloadFactory description="Payload" media-type="json"&gt;
        &lt;format&gt;{
                    "owner": "admin",
                    "clientName": "admin_emm",
                    "grantType":
                    "refresh_token password client_credentials",
                    "tokenScope": "prod"
                    }&lt;/format&gt;
        &lt;args/&gt;
      &lt;/payloadFactory&gt;
      &lt;send receive="Mensaje"/&gt;
    &lt;/inSequence&gt;
    &lt;outSequence/&gt;
    &lt;faultSequence/&gt;
  &lt;/target&gt;
&lt;/proxy&gt;
</code></pre>

<p>This is my sequence that gets the response from the other service in my proxy</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;sequence name="Mensaje" trace="enable" xmlns="http://ws.apache.org/ns/synapse"&gt;
    &lt;log level="custom"&gt;
        &lt;property expression="json-eval($.client_secret)"
            name="client_secret" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
    &lt;/log&gt;
    &lt;log level="custom"&gt;
        &lt;property expression="json-eval($.client_id)" name="client_id" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
    &lt;/log&gt;
    &lt;log level="custom"&gt;
        &lt;property
            expression="fn:concat('Basic ', base64Encode('client_id:client_secret'))"
            name="Authorization" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
    &lt;/log&gt;
    &lt;property name="grant_type" value="password"/&gt;
    &lt;property name="username" value="admin"/&gt;
    &lt;property name="password" value="admin"/&gt;
    &lt;property name="scope" value="default"/&gt;
    &lt;header name="Accept" scope="transport" value="application/json"/&gt;
    &lt;payloadFactory media-type="xml"&gt;
        &lt;format&gt;
            &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
                &lt;soapenv:Body&gt;
                    &lt;root xmlns=""&gt;
                        &lt;grant_type&gt;$1&lt;/grant_type&gt;
                        &lt;username&gt;$2&lt;/username&gt;
                        &lt;password&gt;$3&lt;/password&gt;
                        &lt;scope&gt;$4&lt;/scope&gt;
                    &lt;/root&gt;
                &lt;/soapenv:Body&gt;
            &lt;/soapenv:Envelope&gt;
        &lt;/format&gt;
        &lt;args&gt;
            &lt;arg evaluator="xml" expression="$ctx:grant_type" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
            &lt;arg evaluator="xml" expression="$ctx:username" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
            &lt;arg evaluator="xml" expression="$ctx:password" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
            &lt;arg evaluator="xml" expression="$ctx:scope" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
        &lt;/args&gt;
    &lt;/payloadFactory&gt;
    &lt;property name="ContentType" value="application/x-www-form-urlencoded"/&gt;
    &lt;property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/&gt;
    &lt;call&gt;
        &lt;endpoint name="Token"&gt;
            &lt;http method="POST" uri-template="https://localhost:9443/oauth2/token"/&gt;
        &lt;/endpoint&gt;
    &lt;/call&gt;
    &lt;respond/&gt;
&lt;/sequence&gt;
</code></pre>

<p>Then when i run it i have an error of HTTP/1.1 415 Unsupported Media Type</p>

<p>Please, help</p>