Need help with attaching an image to a Jira issue using the REST API

Mark Hamner March 1, 2024

Hi all!  First time poster :)

I need to attach an image to a Jira issue using the REST API.  

I'm using the standard

/rest/api/2/issue/{issueId}/attachments API call.

Here's the frustrating part:  I can get it to work just fine in Postman using the form data option for the body

jira1.png

But I cannot seem to get it to work using the Raw option and supplying the actual JSON:

Jira2.png

I've tried it both with and without the Type attribute.

It always gives me either an 500 internal server error or a 415 unsupported media type.  This is on the same file as works fine with the form data.  I have my headers set up (I think) correctly for both.

Jira3.png

Is it having a problem with the JSON being a part of the request - is the form data sending something different behind the scenes?

Any help would be greatly appreciated!

Thanks!

Mark

2 answers

1 accepted

1 vote
Answer accepted
Mark Hamner March 1, 2024

Got it working :)

0 votes
Mark Hamner March 1, 2024

Okay, kinda figured some of this out - looks like you have to use the multipart form data to send these attachments, so I've changed my code to do that.  Still having a weird problem where I'm getting a 200 response in my code, but the attachment isn't actually attaching in Jira...

Suggest an answer

Log in or Sign up to answer