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("https://issues.apache.org/jira/"), 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

Accepted Answer
1 vote

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. https://issues.apache.org/jira/rest/api/latest/issue/YOKO-127 or https://issues.apache.org/jira/rest/api/latest/issue/ZOOKEEPER-1707

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 issues.apache.org (AFAIK they used a plugin handling contributions (legal aspects) as issue attachments).

Cheers,

Wojtek

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
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

91 views 3 6
View post

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