Link or Reference an Attachment in a Comment

I am trying to make a comment on an issue through the Rest API that references or links to an attachment inside that issue. I have already successfully attached a PDF file to the issue and now would like to reference that attachment in a comment using the API so that the Service Desk Customer can access the PDF.

Per the API Documentation on Add Comment the body needs to be:

body
anything
The comment text in Atlassian Document Format.

Looking at the Document Format the only option I see is creating a link to the attachment. But when I use the direct link to the attachment the customer doesn’t have access to that link. Is there a different way of doing this?

Thanks!

1 Like

I have done some testing and checking of what happens when a comment is made with a reference to the attachment within the UI and it looks like the link to the document is:

https://{domain}.atlassian.net/servicedesk/customershim/secure/attachment/10111/10111_repair_request_TS-44.pdf?fromIssue=10134

and the link from the comment created through the API is

https://{domain}.atlassian.netservicedesk/customershim/secure/attachment/10111/repair_request_TS-44.pdf?fromIssue=10134

They are really close, but when looking at the Comments through the API I get this:

[^repair_request_TS-44.pdf]

and

[repair_request_TS-44.pdf|https://{domain}.atlassian.net/secure/attachment/10111/repair_request_TS-44.pdf]

Another interesting thing is that after I made the comment in the UI and referenced the same attachment, then both links work in either comment. Before that I received a 403 Unauthorized error when clicking the link from the comment created by the API.

I figured out how to do this. Instead of using the Jira API use the Jira Service Desk API. Under request, there is a Create Attachment function that allows you to create an attachment to the issue and then leave a comment for the customer referencing that attachment.

This worked well and I was able to attach a PDF to the issue and then leave a comment for the customer about that PDF.

1 Like

I wish you post how did you do it?
with example of curl call, screen shots!!!

Good evening!

If you are looking for a reference link for the image(screen capture) in the comment, you can simply find the desired image within the comment section of the Jira ticket, do a right click on the image and choose/select copy image address. From here you should be able to paste link or create a hyperlink to image.

Kind Regards,
Sam