How do I force the HTTP Request Connector to use a

2019-08-22 04:00发布

问题:

In Mule 3.6, I have the following HTTP Request Connector:

<http:request config-ref="IPAM_Request_Config" path="${ipam.path}" method="POST" doc:name="Send SMS to IPAM">
    <http:request-builder>
        <http:query-param paramName="mobile" value="sms.mobile"/>
        <http:query-param paramName="textmsg" value="sms.text"/>
        <http:query-param paramName="receiver" value="sms.receiver"/>
        <http:query-param paramName="mobileoperator" value="sms.operator"/>
        <http:query-param paramName="circle" value="sms.circle"/>
        <http:query-param paramName="time" value="sms.time"/>
    </http:request-builder>
</http:request>

How do I force this to take the Content-Type as application/x-www-form-urlencoded. It is taking text/plain;charset=windows-1252 even though the payload is a org.mule.module.http.internal.ParameterMap.

回答1:

Set the Content-Type manually before the request:

<set-property propertyName="Content-Type" value="application/x-www-form-urlencoded" />


回答2:

You can also set this within the http:request-builder with the following:

<http:request-builder>
    <http:query-param paramName="mobile" value="sms.mobile"/>
    ... other params ....
    <http:header headerName="Content-Type" value="application/x-www-form-urlencoded"/>
</http:request-builder>


标签: java http mule