Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Making a `multipart/form-data` request in Jira Automation

Chris Bonnar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 1, 2023

I'm trying to reproduce a `multipart/form-data` request within Jira Automation. The request is a POST to the Confluence v1 API attachments endpoint, and I have called this successfully using Postman.

However, when running within Jira Automation, I'm receiving code 500: `java.lang.RuntimeException: org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly`.

Researching this error has sent me round in circles with variations of CRLF (or `\r\n`), and I have tried every permutation to no avail. This post looked particularly promising, pointing specifically to the new line before the last boundary - again I experimented to no avail.

The below is the exact request Postman is making for a very simple text file, as captured by Fiddler. I have lifted this exact text into the Jira Automation web request, configuring the same headers Postman is using.


----------------------------882762106784743758392779
Content-Disposition: form-data; name="file"; filename="New Text Document.txt"
Content-Type: text/plain

SampleTextContent
----------------------------882762106784743758392779
Content-Disposition: form-data; name="minorEdit"

1
----------------------------882762106784743758392779--

`Content-Type` header configured in Jira Automation is:

multipart/form-data; boundary=--------------------------882762106784743758392779

 

Where am I going wrong? TIA!

*Side note - I'm doing this because I want to automatically create a Confluence page which carries the same attachments as the Jira issue that triggered it. If anyone is aware of another way to do this, I'd welcome ideas.

3 answers

0 votes
Jawad Haider
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 8, 2024

Hi  @Chris Bonnar @Fabian Ehrler 

I am also trying to achieve the same. Have you got any solution for this?

Regards,

Jawad Haider

Chris Bonnar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 9, 2024

I'm afraid the project moved on and I abandoned what I was trying to do here - I didn't find any solution. Hopefully you do!

Fabian Ehrler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 9, 2024

Same here. Sorry.

Jawad Haider
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 9, 2024

Thanks will create ticket with Atlassian support

0 votes
Fabian Ehrler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 5, 2024

Hi @Chris Bonnar 

Did you manage to get this resolved? I've probably the same challenge right now.
I'd like to get the attachment on issue1 and post it on issue2. Likewise, I get a message like this:

400 - CLIENT_ERROR Stream ended unexpectedly

Using: "Response: {{webResponse.status}} - {{webResponse.statusCategory}} {{webResponse.body}}" as a log action.

 

In my automation workflow, I've set up a "duplicate" post to a Postman mock server instance, so that I can see what happens (or at least sort of). Interestingly, this body I receive this way looks quite okay to me:
Screenshot 2024-01-05 170714.png

When I copy & paste this exact body, and execute the request from postman (same headers etc.), the upload is successful, and I'm able to see the attachment on the issue. Strange.

 

The Custom data that I'm posting looks something like this, btw:

--{{formBoundary}}
Content-Disposition: form-data; name="file"; filename="{{filename}}"
Content-Type: application/octet-stream

{{webResponse.body}}
--{{formBoundary}}--

 

Something seems to be still interacting with the body, or I'm overlooking something.

 

Regards,
Fabian 

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2023

Hi @Chris Bonnar -- Welcome to the Atlassian Community!

As you appear to be on a paid, Jira license, you may want to work with your site admin to submit this one as a support ticket to Atlassian here: https://support.atlassian.com/contact/#/

In the meantime, you could also ask this one in the developer community here: https://community.developer.atlassian.com/

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events