How do I get the list of attachments using JIRA API with Java? I don't need the attachments I just want to know what attachments are there, and their ID. I followed basics of using a query to get issues and I am getting issues but not their attachments. My code:
[String searchQuery = "(created >= '2015/12/1' ) AND (created < '2016/01/1')"
JiraAuthentication jiraAuth;
JiraRestClient arc;
// Get JiraAuthentication instance to create basic HTTP authentication
// string
jiraAuth = JiraAuthentication.getInstance();
// Make sure you use a new instance
jiraAuth.initInstance();
jiraAuth = JiraAuthentication.getInstance();
// Get the JIRA Rest Client from the basic HTTP authentication
jrc = jiraAuth.getJrc();
// Receive search results based on query
SearchRestClient searchClient = jrc.getSearchClient();
// limit results to 50
SearchResult result = searchClient.searchJql(searchQuery, 50,0, null);
Iterator<BasicIssue> itIssue = result.getIssues().iterator();
// pull information on individual issues.
while (itIssue.hasNext()) {
BasicIssue lBasicIssue = (BasicIssue) itIssue.next();
String lIssueKey = lBasicIssue.getKey();
Issue issue = jrc.getIssueClient().getIssue(lIssueKey, null);
//This line should print the list of attachments. but everything is always null.
System.out.println(issue.getAttachements());
}][1]
One example where I am trying to get information is from HBASE-15062, which has the api link. In the api link there doesn't show any attachments but in the actual link there are 4 attachments.
I know about the Jira api call api/2/issue/{issueIdOrKey}/attachments
.
I tried : api/2/issue/12925031/attachments
I get the response HTTP Status 405 - Method Not Allowed
Does this mean I cannot get attachment list or am I just doing the request wrong?
How can I change my java code to get the attachments? Is getting attachments possible from the APACHE JIRA?