Get image from a comment in a jira issue

@GhattasHaithem

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": "https://solidinterface.atlassian.net/rest/api/3/attachment/10017",
                "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": "https://solidinterface.atlassian.net/rest/api/3/attachment/content/10017"
            }
]

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