1
votes

I am trying to add attachments to JIRA issue using JIRA rest api. I am using mulesoft to develop this flow. But I am not able to figure out how to send a file using request connector in mule 4. JIRA only accepts file in the form of multipart content type.

I went through some of the documentation and it seems that till mule 3 using set attachment we can do this. In mule 4 dataweave is used to achieve this functionality but i am not able to find working code that can be used to implement this.

1
This works for me, please update the question with any errors that you come across. dzone.com/articles/… - utechtzs

1 Answers

1
votes

From the HTTP Connector tests:

<http:request config-ref="requestConfig" path="/" method="POST">
    <http:body><![CDATA[
                #[
                %dw 2.0
                output multipart/form-data
                ---
                {
                parts : {
                    partOne : {
                        headers : {
                            "Content-Type": "text/plain",
                            "Custom" : "myHeader"
                            },
                        content : "content 1"
                        },
                    partTwo : {
                        headers : {
                            "Content-Disposition" : {
                                "name": "partTwo",
                                "filename": "a.html"
                                },
                            "Content-Type" : payload.^mimeType
                            },
                        content : payload
                        }
                    }
                }]
    ]]></http:body>
</http:request>

This will send a two part message:

  • The first named "partOne" with text/plain "content 1"
  • The second named "partTwo" and filename "a.html" using the current payload

You can find more information on handling multipart content here.