Jira REST API - Attach file at the same time as creating an issue - Can it be done?

Jacob Watts February 7, 2020

I have a demo of issue collector setup and working. But some of the limitations - like the cascading select list - have me considering the REST API. We definitely want users to be able to submit attachments when they create issues. Our current production solution doesn't allow them and it's a big part of why I started working on issue collector.

I've been researching the REST API and what I'm finding, so far, seems to be that I'd have to create the issue first and then attach the file.

Is that still the current behavior?

2 answers

1 vote
Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2020

Dear @Jacob Watts ,

so it is. The reason is simple. Creating an issue required posting JSON payload. Adding an attachment required posting a MultiPartMime. Both the same time is not possible at the moment.

So long

Thomas

Jacob Watts February 7, 2020

Thank you @Thomas Deiler 

Thats a pretty big limitation.

How hard would it be to have backend code create the ticket. Then use the returned ticket ID(I believe I read it can return that upon ticket creation) and then use that ID to attach a file all with the same submit button press?

Is there existing code anyone has written to do something like this?

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2020

Dear @Jacob Watts ,

it's not a big deal. When creating the issue, you get the new issue key returned in the JSON response. Then posting the attachment is as simple as described in the api documentation.

So long

Thomas

Jacob Watts February 7, 2020

Thanks, hopefully they make it easier in the future!

Mithila Lishan April 21, 2024

After 4 years still are there not a alternative solution for this issue ? 

Like Daniel Luevano likes this
0 votes
YongAn Yang
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!
June 4, 2024

Do I need to create the issue first and get the issue number before I can upload attachments?

Mithila Lishan June 4, 2024

Yes there are 2 APIS for issue creation and Upload attachment. After issue created based on the issue number you recived you need to invoke attachment API and upload attachment

YongAn Yang
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!
June 4, 2024

thx

Suggest an answer

Log in or Sign up to answer