# Link or Reference an Attachment in a Comment

**URL:** <https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716>\
**Category:** Jira Cloud\
**Tags:** jira-service-management, jira-cloud, rest-api\
**Created:** [January 31, 2019, 6:11pm UTC](https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716 "2019-01-31T18:11:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg.russon](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/greg.russon/32/37260_2.png) [@greg.russon](https://community.developer.atlassian.com/u/greg.russon)\
**Post date:** [January 31, 2019, 6:11pm UTC](https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716/1 "2019-01-31T18:11:18Z")

</div>

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](https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/).

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!

---

<div class="post-metadata">

**Author:** ![greg.russon](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/greg.russon/32/37260_2.png) [@greg.russon](https://community.developer.atlassian.com/u/greg.russon)\
**Post date:** [January 31, 2019, 6:29pm UTC](https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716/2 "2019-01-31T18:29:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![greg.russon](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/greg.russon/32/37260_2.png) [@greg.russon](https://community.developer.atlassian.com/u/greg.russon)\
**Post date:** [February 6, 2019, 7:44pm UTC](https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716/3 "2019-02-06T19:44:35Z")

</div>

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](https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-rest-servicedeskapi-request-issueIdOrKey-attachment-post) 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.

---

<div class="post-metadata">

**Author:** ![EklasAldwairi](https://avatars.discourse-cdn.com/v4/letter/e/3bc359/32.png) [@EklasAldwairi](https://community.developer.atlassian.com/u/EklasAldwairi)\
**Post date:** [April 10, 2022, 3:17am UTC](https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716/4 "2022-04-10T03:17:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SamuelFrancis](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@SamuelFrancis](https://community.developer.atlassian.com/u/SamuelFrancis)\
**Post date:** [March 20, 2023, 12:06am UTC](https://community.developer.atlassian.com/t/link-or-reference-an-attachment-in-a-comment/26716/5 "2023-03-20T00:06:53Z")

</div>

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
