I have to create a multipart/form-data HTTP request where the file will be received from one request, some additional form data values from different requests. Example:
1) HTTP listener receives the file as attachment
2) Sends HTTP requests to 3 or more REST APIs, and stores values into property variables
3) Create a HTTP request with the file received in step 1 along with values received in step 2
When I receive the file in step 1 I save it in a property, I also save values from subsequent requests into different properties.
Now When I construct a HTTP POST request from these properties in Step 3 I don't receive any values on the server, neither the fields nor the file.
My Flow:
<http:request-config name="HTTP_poster_Configuration" host="localhost" port="53536" doc:name="HTTP Poster Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="1.1.1.1" basePath="/xyz" port="8080" doc:name="HTTP Request Configuration"/>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="getticketFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<set-session-variable variableName="var1" value="NA" doc:name="Session Variable" />
<set-variable variableName="var2" value="P11335577" doc:name="Flow name Variable" />
<set-variable variableName="var3" value="Goku" doc:name="Flow title Variable" />
<set-variable variableName="var4" value="Saiyan Dead but Alive" doc:name="Flow description Variable" />
<set-variable variableName="uploadFile" value="#[message.inboundAttachments['file'].dataSource.content]" doc:name="Flow type Variable" />
.................Sending requests to other services
...................Setting property Variables
<!-- Finally -->
<http:request config-ref="HTTP_poster_Configuration" path="/handler" method="POST" doc:name="Uploading_Doc" >
<http:request-builder>
<http:query-param paramName="filedata" value="#[flowVars ['uploadFile']]"/>
<http:query-param paramName="sid" value="#[flowVars ['var1']]"/>
<http:query-param paramName="cid" value="#[flowVars ['var2']]"/>
<http:query-param paramName="udi" value="#[flowVars ['var3']]"/>
<http:header headerName="Content-Type" value="multipart/form-data"/>
</http:request-builder>
</http:request>
</flow>
</mule>
If what you want is to send the file and the other data in a multipart request then you need to add everything as attachments, not query params as in your flow right now. Each attachment will then translate to a "part" in the request.
So before the final request
you need to use the set-attachment
component.
You can find more on this here.