Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

1 vote
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
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.



Hello @Andy Heinzer 
is it possible now to post a comment with attachment directly?

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jan 18, 2022

The REST API in Jira can perform both of those functions. However they are still required to happen within two separate REST API calls.  Users have sought to have a single REST API Post call that can add a new attachment, and then perform some other action, such as creating an issue or adding a comment to an existing issue. 

While that is possible to do within the web interface, the REST API is limited in this regard.  There are feature requests for this behavior over in

Hey @Andy Heinzer,

the approach you are mentioning only works when entering the string directly as a comment. When sending it via an API post request, jira transforms 





How do I avoid these atomatic backslashes?




Suggest an answer

Log in or Sign up to answer