0
votes

I trying to retrive a token OAuth2. But I don't khnow how I can make a x-www-form-urlencoded request using wso2esb. This is a snippet of my code:

 <?xml version="1.0" encoding="UTF-8"?>
<sequence name="test-oauth_v1" xmlns="http://ws.apache.org/ns/synapse">
    <in>
        <property name="RESPONSE" scope="default" value="true"/>
        <property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
        <header action="remove" name="To"/>
        <property name="messageType" value="application/json" scope="axis2" type="STRING"/>
         <property name="basicAuth" scope="default" type="STRING" value="Z3FZVFhUQnhkQlVGNDloblxxzedtSGRBQ1kySWpmSmNvZXdh"/>


        <script language="js"><![CDATA[

            var body = {};
            body.grant_type = 'password';
            body.username = 'xxxx';
            body.password = 'xxxxxxx';
            mc.setPayloadJSON(body);

        ]]></script>    

        <property name="messageType" scope="default" type="STRING" value="application/x-www-form-urlencoded"/>
        <header
            expression="fn:concat('Basic ', get-property('basicAuth'))"
            name="Authorization" scope="transport" xmlns:ns="http://org.apache.synapse/xsd"/>
        <call>
            <endpoint key="server_token_oauth"/>
        </call> 

        <send />
    </in>
</sequence> 

Would you have any propositions ?

Best regards

1

1 Answers

0
votes

You can refer this example [1]. Scope of the messageType should be axis2.

<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/>     
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/>