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

This widget could not be displayed.

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.

This widget could not be displayed.

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.

This widget could not be displayed.

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.

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

180 views 18 7
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