Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

JIRA Rest API Comments attachment link in renderBody html

Recently we have integrated the Jira Rest API into a custom support portal product we are developing in house. I am attempting to create a web component that displays comments on an issue and any attachments within the comments as clickable thumbnails that can be downloaded once the user clicks the thumbnail. 

Below is my rest call:

I am using renderBody to output the comment as HTML but have ran into an issue. 

Here is a sample of the renderBody output which I then display in a div within my component. 

"renderedBody": "<p>By default, cards take all the available width in their parent container, but you can use the <tt>width</tt> and <tt>max-width</tt> classes to control take control of the card’s dimensions. So, let’s change the previous example by reducing the width of the card:</p>\n\n<p><span class=\"nobr\"><a href=\"/secure/attachment/12494/12494_Snippet.cs\" title=\"Snippet.cs attached to XER-11\" data-attachment-type=\"file\" data-attachment-name=\"Snippet.cs\" data-media-services-type=\"file\" data-media-services-id=\"aa14ccc7-a4d3-4803-bba3-9353332c7e5e\" rel=\"noreferrer\">Snippet.cs<sup><img class=\"rendericon\" src=\"/images/icons/link_attachment_7.gif\" height=\"7\" width=\"7\" align=\"absmiddle\" alt=\"\" border=\"0\"/></sup></a></span></p>\n",

The problem is it includes the attachment as a link that appears to go no where what does /secure/attachment/12494/12494_Snippet.cs correspond to?

It would be ideal to have a way to return a renderBody without the attachment links then I could handle them myself. Or I will have to find a way to parse out the attachment links from the renderBody output. Is there a way to use renderBody and omit the attachment links?

1 answer

0 votes

Hello Nathan and welcome to the Community!

The REST API endpoint you're using will return the comment data, however, it will not return the full path to any attachments as the attachments themselves will be associated with the issue itself. The URL you're seeing returned is the URL to locate the attachment within the issue.

Ideally, you'll need to build an array of any/all comments from there pull the attachments using GET /rest/api/3/attachment/{id} (This won't give you the attachment itself, but will include the URL where the attachment is stored, example:

: "2021-05-21T07:17:06.858+0000",
"size": 23123, "mimeType": "image/jpeg",
"content": "",
"thumbnail": "" }

From your example above;


You can see the attachment ID, which in this case is '12494'. You'll use this ID against the endpoint listed above to then get the metadata and from there add the 'content' URL to have the direct path URL to the attachment.

Hope this information proves helpful.

Stephen Sifers

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked in Jira Service Management

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

262 views 13 14
View question

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