How to send attachments to a comment through the REST API?

agomez0207 July 12, 2017

Hello, I am trying to send a comment through the REST API but I don't see in the documentation a valid endpoint to send an attachment to a comment, thanks

3 answers

1 accepted

1 vote
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 19, 2017

In JIRA, attachments are not bound to comments, but rather to specific issues in JIRA.  There is way add attachments in JIRA via REST, the endpoint in JIRA is /api/2/issue/{issueIdOrKey}/attachments

https://docs.atlassian.com/jira/REST/server/#api/2/issue/{issueIdOrKey}/attachments-addAttachment

agomez0207 July 19, 2017

Thanks

Chris Gembarowski April 22, 2019

From the point of view of us users this is a lie.  The GUI very clearly allows the user to add an attachment via a comment.

Like # people like this
Rishi Sharma January 31, 2021

Yes! The GUI has a clear segregated way to provide attachments to a comment and that shows in the comment itself.

Melvin Corbes June 15, 2023

I'm trying to duplicate the functionality of the JIRA interface in Salesforce, but I'm having some trouble. I've been able to add files and comments, but I'm unable to attach a file to a comment. Do you have any ideas or possible fixes for this problem?

1 vote
Jesse Maxwell September 30, 2023

Here's the concept:

  1. Upload the attachment
  2. Include in the comment like this: 
"!sebastien-jermer-n7DY58YFg9E-unsplash.jpg|width=2048,height=1536!\n\nThis is a sample image."
jomo October 24, 2023

The problem here is that jira escapes the added image with backslashes. 

 

!logo.png|!    becomes => \!logo.png\|\! 

and will therefore not be displayed on the comment.

Any way to avoid this?

1 vote
Stephen Deutsch
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.
July 13, 2017

There are some examples of using the API here:

 

https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples

but maybe you can explain better what you are trying to do?

If you want an attachment to be diplayed inside a comment, you will probably have to first attach the attachment to the page (I don't think you can attach an attachment to a comment, only to its parent page), and then submit a comment with the necessary storage format (you can look at the storage format of an attachment displayed in a page to see what you need).

Suggest an answer

Log in or Sign up to answer