It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to attach a text file to a comment to jira ticket using REST API?

Hi, I would like to attach a text file to a comment in Jira issue via REST API.
I see that it is possible over web interface, so I assume it is also possible via REST API.

1 answer

0 votes
Andy Heinzer Atlassian Team Nov 12, 2019

Hi @dmytrob 

I understand that you are looking for a way to attach a text file to a comment in Jira using the REST API.  This can be done, but it technically requires two different REST API POST commands to two different REST endpoints to make this work.

In order for you to be able to link to an attachment in the comments or description of a Jira issue, that attachment has an expectation that it will have already been uploaded to that specific Jira issue.  Once that is true, you can then reference that attachment via the wiki-markup of the comment itself.

Check out the Jira Server REST API reference for POST /rest/api/2/issue/{issueIdOrKey}/attachments.  That explains how you can add an attachment to a Jira issue first.  Once that command has completed, you can then add a comment using the endpoint POST /rest/api/2/issue/{issueIdOrKey}/comment.  If the filename that is uploaded to that Jira issue is called example.txt then the body of that comment should contain some wiki-markup like this:

Here is a link to the [^example.txt] file.

That should then permit your comment to have a link directly to that attachment on that issue.

Let me know if you have any questions about this.

Cheers,

Andy

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

363 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you