Getting issue attachments in JRJC

When I get a list of issues from a search, how can I get the list of attachments for an issue? Using this code:

JiraRestClient c = j.create(new URI(""), new AnonymousAuthenticationHandler());
  IssueRestClient irc = c.getIssueClient();
  Issue is = irc.getIssue(issueKey).get();
  if (is == null || is.getAttachments() == null) return Lists.newArrayList();
  return Lists.newArrayList(is.getAttachments());

is.getAttachments always returns null, even when there are attachments. And I don't see another way of asking for just the attachments for one issue. (Using version 2.0.0-m3).

4 answers

1 accepted

1 vote
Accepted answer

Issue.getAttachments() is the way to go ... provided that there is attachment info sent by the server.

I think your problem is specific to JIRA instance side used by Apache.

I've just checked a few random issues which do have attachments and their REST representation does not include "attachment" information at all.

E.g. or

I don't recall any issue in JIRA itself about missing attachment info in REST representation of an issue. I've checked on some other instances (like JIRA 5.2.10) and there attachment info in REST is present.

I suppose this problem may be caused by some configuration issue or a mis-behaving plugin installed on (AFAIK they used a plugin handling contributions (legal aspects) as issue attachments).



Super, thanks Wojciech! I'll ping the folks at Apache to see why this is set this way.

Hey did you ever end up fixing this? I have iterated through all of my attachments and issue.getAttachments() is returning null for each attachment. Does anyone have any suggestions? Thansk! I'm using version 2.0.0-m2.

Hey Victor - no, didn't get this resolved, but as Wojciech points out, the problem isn't on the JRJC side, but instead on the API output itself (at least in my case). If you view the raw REST output in a browser and see that there's no attachments there, you're in the same boat. No idea how to resolve that, except maybe as an upgrade or settings change on the JIRA repo itself.

Ah kk, yea I am not seeing any attachments in the REST output. Do you think forcing it to use an older version of the API or tricking it into thinking that it is using an older version of JIRA will work?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Agile

How Scrum works? It starts with training and education

To answer “How scrum works,” most of the teams I've worked with first addressed the question: “where to start?”  That question applies to both implementation and improvements on the Scrum framew...

100 views 3 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you