Downloading issue attachments via JIRA API in Java

J M January 3, 2017

I am creating a webpage where the user will be able to view the thumbnails of attachments for an issue, and when clicking on a thumbnail, the browser will load the attachment itself.

I can load all of an issue's details onto the page by using the API (e.g. the webpage shows the key, issue type, description, priority, attachment info, etc.), however the problem is that when I try to create a thumbnail for an attachment, it does not load the image in the browser. When clicking on that thumbnail to load the attachment, it redirects to the official JIRA page for the user to login.

This is the code on my webpage for loading the content, I am getting the content and thumbnail URLs from the JSON data returned from calling "GET /rest/api/2/issue/{issueIdOrKey}":

<a href="{{attachment.content}}">
	<img src="{{attachment.thumbnail}}" height="32" width="32" />
</a>

I understand this can be resolved once logging in via the official JIRA page, however my webpage already has a login page where the user enters their credentials and can then view issue details once successfully logged in, so I don't want users to log in twice. My webpage uses cookie-based authentication for logging in users.

Is there a way to resolve this so the webpage can load attachment thumbnails and content without requiring a second login?

1 answer

0 votes
Robert Massaioli _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2017

What are you actually trying to accomplish here? On a higher level? Maybe there is already an add-on in the Atlassian Marketplace. Or maybe you would be better off writing this as an Atlassian Connect add-on: connect.atlassian.com

Suggest an answer

Log in or Sign up to answer