Jira REST attachment JSON returns a ‘content’ URL, but non-PNG downloads trigger a login request even with Basic auth. Sample code below:
try (CloseableHttpClient clientConn = HttpClients.createDefault()) {
HttpGet requestObj = new HttpGet("your_attachment_endpoint");
requestObj.setHeader("Authorization", "Basic yourEncodedAuth");
try (CloseableHttpResponse respObj = clientConn.execute(requestObj)) {
// Process the response
}
}
The issue may be related to how the server treats different file types, not solely an authentication error. In my experience with Jira, ensuring that the client maintains the session cookie along with the basic authentication header can be crucial for certain file types. Additionally, verifying that the URL provided in the JSON response is fully qualified with proper query parameters may help avoid redirection to login. Another potential workaround is to use a session-based authentication method if basic auth does not suffice for your specific endpoint.