Created
July 11, 2012 21:21
-
-
Save jdeoliveira/3093611 to your computer and use it in GitHub Desktop.
Mule flow to PUT form encoded data through HTTP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<flow name="httpputFlow" doc:name="httpputFlow"> | |
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8086" doc:name="HTTP"/> | |
<scripting:component doc:name="Groovy"> | |
<scripting:script engine="Groovy"> | |
<scripting:text> | |
<![CDATA[ | |
HashMap map = new HashMap(); | |
map.put("param1", "value1"); | |
map.put("param2", "value2"); | |
map.put("param3", "value3"); | |
return map; | |
]]> | |
</scripting:text> | |
</scripting:script> | |
</scripting:component> | |
<scripting:component doc:name="Groovy"> | |
<scripting:script engine="Groovy"> | |
<scripting:text> | |
<![CDATA[ | |
message.payload = payload.collect { k,v -> "$k=$v"}.join('&'); | |
]]> | |
</scripting:text> | |
</scripting:script> | |
</scripting:component> | |
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" method="PUT" doc:name="HTTP"> | |
<properties> | |
<spring:entry key="Content-Type" value="application/x-www-form-urlencoded"/> | |
</properties> | |
</http:outbound-endpoint> | |
</flow> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now it's not required to create the Form payload manually. When the HTTP Request connector receives a Map object, it will send the Form URL Encoded request, including the Content-Type.
https://docs.mulesoft.com/mule-user-guide/v/3.8/http-request-connector#generate-the-request-body-with-content-type-application-x-form-urlencoded
The Map can be created with Dataweave. For example: