I am migrating a application from mule-3 to mule-4. Facing issue while posting multi-part/form-data in mule-4. mule-3 configuration is like this for setting attachments of multipart form data. first in mule-3 i am getting base64 from a http component which looks like below.
and after that. I am using transform message component to decode the payload
then the calling the following flow for posting data
<flow name="wbg_ebiz_wfa_wb_docs_upload_attachments">
<set-payload value="#[null]" doc:name="Set Payload"/>
<set-attachment attachmentName="SITE_KEY" value="#[flowVars.dotnetVar.SITE_KEY]" contentType="text/plain" doc:name="SITE_KEY"/>
<set-attachment attachmentName="I4_KEY" value="#[flowVars.dotnetVar.Key]" contentType="text/plain" doc:name="I4_KEY"/>
<set-attachment attachmentName="I4_XML" value="#[flowVars.dotnetVar.metadata]" contentType="text/plain" doc:name="I4_XML"/>
<set-attachment attachmentName="I4_APP_ID" value="ESB_BUSINESS" contentType="text/plain" doc:name="I4_APP_ID"/>
<set-attachment attachmentName="#[flowVars.dotnetVar.FileName]" value="#[sessionVars.dotnetResVar]" contentType="binary/octet-stream" doc:name="File Attachment"/>
<logger message="#[flowVars.dotnetVar.FileName]" level="INFO" doc:name="Logger"/>
<set-attachment attachmentName="fileName" value="#[flowVars.dotnetVar.FileName]" contentType="text/plain" doc:name="FileName"/>
<logger level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_WB_DOCS_Request_Configuration" path="/services" method="POST" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="I4_SERVICE" value="ADD_DOC"/>
<http:header headerName="HOST" value="aa.cc.org"/>
<http:header headerName="Authorization" value="#[flowVars.access_token]"/>
<http:header headerName="Content-Type" value="multipart/form-data"/>
</http:request-builder>
<http:success-status-code-validator values="100..550"/>
</http:request>
<logger message="payload from wbdocs #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</flow>
in mule-4 up to step-1 is fine. am able to get base64 string i tried to decode base 64 string using the following code
then after that I used the follwing code to construct parts
%dw 2.0
import dw::module::Multipart
output multipart/form-data
---
{
"parts": {
"I4_KEY":{
"headers": {
"Content-Type": "text/plain",
"Content-Disposition": {
"name": "I4_KEY",
subtype: "form-data"
},
},
"content": vars.I4_KEY as String
},
"SITE_KEY": {
"headers": {
"Content-Type": "text/plain",
"Content-Disposition": {
"name": "SITE_KEY" as String,
subtype: "form-data"
},
},
"content": vars.SITE_KEY as String
},
"I4_APP_ID": {
"headers": {
"Content-Type": "text/plain",
"Content-Disposition": {
subtype: "form-data",
"name": "I4_APP_ID" as String
},
},
"content": "ESB_EBUSINESS" as String
},
"I4_XML": {
"headers": {
"Content-Type": "text/plain",
"Content-Disposition": {
subtype: "form-data",
"name": "I4_XML" as String
},
},
"content": vars.I4_XML as String
},
"fileName": {
"headers": {
"Content-Type": "text/plain",
"Content-Disposition": {
subtype: "form-data",
"name": "fileName" as String
},
},
"content": "Togo Country ASL.pdf"
},
"Togo Country ASL": {
"headers": {
"Content-Disposition": {
"name": "Togo Country ASL",
subtype: "form-data",
"filename": "Togo Country ASL.pdf"
},
"Content-Type": "application/octet-stream"
},
"content": read(vars.dotnetResVar, "application/octet-stream")
}
}
}
this payload for multipart/form-data request in mule-4 throwing 500 internal server error.


