How to get last uploaded attachment from a JIRA issue with JIRA REST GET URI (JIRA Query Language)

Preetam November 25, 2017

Dear All,

I have two questions. If you could help me with any one of those, I would be very grateful.

1) I have few criteria to search a particular issue. Now I want to get the last updated attachment information from that issue. The issue have number of other attachments in .csv format. However, I want only the last uploaded one. Is there any function or reference keyword in the JQL to achieve the same.

2) Also could you please let me know how do I access the nested child elements of attachments and get a restricted JSON response with only intended attachments attribute.

Example: 

Issue: {

Fields:

{

  Status:

  Issue Type:

  Attachments:

{

id:

created:

content:

self: // I want the JSON response against the GET query results me only the four attributes, id, created, content and self url.

........................................................

......................................................

}

}

 

 

1 answer

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 28, 2017

In regards to part #1, there is a problem with this approach.  Jira's JQL is designed to search for Jira issues.  Meaning that JQL is designed to return Jira issues.  It's not designed to return the attachments contained within these issues natively. 

Jira's native JQL does have a "Attachments" field you can search in JQL.  But these only can be used search for whether an issue in Jira has an attachment or not.  It can't be used to search for the latest attachment on that issue.   So in regards to your first part, there is not a way to do this natively with Jira.

That said, you might be able to use a plugin in Jira to add some more of this kind of functionality.  There are a number of add-ons for Jira that extend the functionality around attachment management.  I would recommend searching our marketplace to find these: https://marketplace.atlassian.com/search?product=jira&query=attachment

From this list of plugins I found this one: https://marketplace.atlassian.com/plugins/com.infosysta.jira.JAM/server/overview

It appears that the use of this plugin adds new JQL functions that can extend the searching for attachments in Jira.   While this isn't exactly what I think you are looking for, this plugin would allow you to at least search specifically for attachments added between certain time periods.

Suggest an answer

Log in or Sign up to answer