You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Within some fields in JIRA, images can be added inline such as in the description or in comments. Although they appear inline, they are seemingly being added as attachments and then JIRA is maintaining a link somewhere. Unfortunately, I'm struggling to figure out what that link is when using the API.
Calling /rest/api/3/issue/<issue-key> against an issue where an image has been added inline returns the following:
After uploading an image attachment, you can do an HTTP request to fetch the attachment content, which will redirect to a media URL. The media ID that you need can be extracted from this media URL. You can get the media URL by doing a HTTP GET without automatically following redirects. There's no need to actually fetch the image, just look at the redirect URL (in the HTTP "Location" header).
For example, when adding an inline image to the description, you can get the media ID in this way, then update the description or comment to use that image. I've tested this just now, and it works.
Here's an example.
If this is the main attachment URL:
When we fetch it, the JSON contains a "content" property, which would be:
When we do an HTTP GET on this content URL, it redirects to another URL using the Location header:
We need that UUID "12345678-1234-1234-1234-123456789abc" that comes after /file/ in the redirected URL, this is the media ID.
You can then use that media id in the ADF, something like this:
If you need to go the other way, and find the attachment ID (12345) given the media ID (12345678-1234-1234-1234-123456789abc), you could scan all the issue's attachments one by one in this way. In our case, we are tracking these attachment IDs and media IDs along with some other information in a database, so we don't have to query every attachment each time.
Ah, thanks for the guidance. Found it using my browser console, but still stuck on trying to find this location header using http get through 'Automation For Jira' as a header response.