Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How build an URL preview from attachment?

Angel
Contributor
May 6, 2025

Hi,

We need buid an URL with the preview of picture attachment, Is possible? 

We have Jira-Cloud

Regards,

1 answer

0 votes
Darryl Lee
Community Champion
May 7, 2025

Hi @Angel --

So... I first looked at this question in the context of an external website/service where you might want to include an inline preview of an image from a Jira ticket:

Assuming that the user viewing the URL is logged into Jira, you could use the get issue API endpoint like this:

https://YOURSERVER.atlassian.net/rest/api/3/issue/BUG-11?fields=attachment

Which will return JSON that includes this link:

"thumbnail": "https://YOURSITE.atlassian.net/rest/api/3/attachment/thumbnail/10038"

Thumbnail images can be displayed inline.

The link to the actual image unfortunately has a the headers that cause browsers to interpret it as a download:

"content": "https://YOURSERVER.atlassian.net/rest/api/3/attachment/content/10038",

BUT!

Based on your other question about Smart Values, I'm going to guess that maybe you're trying to create an Automation that sends an email that includes an image?

Huh. I've never tried that. I'm guessing it will probably fail because the mail client will not be "logged in" to Jira, and so won't have permission to load the image.

All this is to say, we're going to need a little more context.

Thanks!

Angel
Contributor
May 8, 2025

Hi @Darryl Lee 

The use case is that a user would acces directly to an image by a customfield with this URL that shows in jira board, also the user had acces to the Jira site.

Darryl Lee
Community Champion
May 8, 2025

Interesting.

I tried it. Unfortunately when I pasted in the thumbnail endpoint, it opens the image in a separate tab.

Pasting in the content endpoint, clicking the link results in downloading the image.

When testing, something that I found interesting is the option to Edit cover image for a card:

image.png

Huh, I wonder if there's an API endpoint to set that...

Oh yeah, some graphql (not my favorite):

So... It's a POST to

https://MYHOST.atlassian.net/gateway/api/graphql/pq/abe9efd99e9999c999999999dea2ef69a762dba11ed3e40c03fbe7d13045a4c?operation=setCardCoverMutation

With this payload:

{operation
setCardCoverMutation
{"operationName":"setCardCoverMutation","variables":{"issueId":"ari:cloud:jira:CLOUD_ID:issue/10046","attachmentId":"10038"}}

Where 10046 is the ID of my Jira Issue, and 10038 is the ID of the attachment.

The big mystery is, WTF is abe9efd99e9999c999999999dea2ef69a762dba11ed3e40c03fbe7d13045a4c

(That's not actually the number. I've replaced some numbers.)

It seems to be consistent across different boards and projects. But seems unique to this particular operation. (Other graphql/pq calls have different IDs.)

It might be interesting to sniff your own mystery ID, and then after making the API calls to get the issue and attachment IDs, try making another API call to your unique API endpoint and see if it updates the image.

Here's how I do this kind of hackery to find the mystery ID:

Open up the Developer Panel in Chrome, then manually add an image to a card.

If you search in the Network tab for setcardcovermutation, then it should find the call that was made when you added an image.

image.png

If you click on that call, and look at the Payload tab, you can View source to see the graphql query, which is pretty straightforward:

image.png

References:

 

Darryl Lee
Community Champion
May 8, 2025

Oh yeah, have to be ok with having your board be full of images, like this, hehe:

image.png

(Sorry, random images I had in my Downloads/Desktop folder.)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events