Get image from a comment in a jira issue

is there any possible way , to get an image in a comment of an issue ,
basically i’m using jira issue comments rest api , but i’m getting this




i mean i need to access the image but all im getting is an id

Hello @GhattasHaithem

… which means the REST API is working exactly as documented.

First, you get the comment, which gives you the IDs of any attachments, then you get the attachments based on their IDs.

1 Like

hey , thank you for your reply :slight_smile:
Yes the api is working exactly as documented
i couldn’t find any Rest-API that i can use to get an attachement based on its id ,
Do you have any solution/suggestion ?
thank you

I suggest that using Google is the solution.

I did a Google search for ‘Jira cloud rest api get attachment based on ID’ and the very first result was the answer.


that id is for the attachement id , not the file id …
the comment Rest-api is giving me this :
[{“type”:“paragraph”,“content”:[{“type”:“text”,“text”:"random with image "}]},{“type”:“paragraph”,“content”:[{“type”:“text”,“text”:"and a hardbrak "}]},{“type”:“mediaSingle”,“content”:[{“type”:“media”,“attrs”:{


the file id is : 58d76091-cf2b-41a9-a797-f2f755693717

So using Google is not a solution :slight_smile:


I think you’re confusing what you’re seeing in the ADF of the Comment body (the media node’s ID) with the ID of the Issue’s attachment, the file itself, which you can obtain via the GET Issue endpoint, and the JSON response contains something like this:

"attachment": [
                "self": "",
                "id": "10017",  <-- IS THIS THE ID YOU MEAN?
                "filename": "test.txt",
                "created": "2022-09-07T09:23:28.203+1000",
                "size": 509,
                "mimeType": "text/plain",
                "content": ""

If you need a quick and dirty way to get that ID when getting the Comment, get the HTML rendered output. You do this by adding the expand parameter to your request and expanding renderedBody, which will produce some extra JSON content, something like this:

"renderedBody": "<p>This comment refers to the </p><p><span class=\"image-wrap\" style=\"\"><img src=\"/rest/api/3/attachment/content/10017\" height=\"492\" width=\"708\" style=\"border: 0px solid black\" /></span></p><p> attachment with the name test.txt</p>"

See, there is the ID of the attachment, the file, at the end of the src path to it.

I really think you’d be best served by spending some time learning more about how Jira’s REST API and ADF represents media, then spending some time looking at prior threads like this one or this one in this forum, or this one in the public community forum where other people have discussed this topic before.

Have fun on your learning journey.

1 Like