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

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 Join to answer
Community showcase
Maarten Cautreels
Posted Thursday in Off-topic

Friday Fun: What's your favourite beer/drink

As a Belgian, beer-lover and home brewer, beer is one of my great passions. I love the fact that with just a few ingredients (usually just water, hop and malt) you can create so many different tastes...

285 views 38 9
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot