JRJC: add and retrieve issue web link

James Bostock January 21, 2020

Hi,

Jira supports links from issues to other issues and also links to external Web pages. For example:

jira-issue-links.png

The Issue.getIssueLinks() method appears to only retrieve links to other issues and not the link to the external Web page. E.g., the following code:

System.out.format("Start dumping links for issue %s%n", issue.getKey());
for (IssueLink il : issue.getIssueLinks()) {
System.out.format("- Issue link: %s%n", il);
}
System.out.format("End dumping links for issue %s%n", issue.getKey());

Causes the following to be printed:

Start dumping links for issue OPP-14
- Issue link: IssueLink{targetIssueKey=OPP-7, targetIssueUri=https://deljirauat/rest/api/2/issue/54357, issueLinkType=IssueLinkType{name=Relates, description=relates to, direction=OUTBOUND}}
End dumping links for issue OPP-14

Using the Java REST Java Client (I am using version 5.1.6):

  • How does one retrieve links to Web pages?
  • How does one add a link to a Web page to an issue?

Thanks,

James

 

2 answers

0 votes
Michal Zawalski October 27, 2021

For anyone using JRJC - it actually supports remote link endpoint. 

RemoteIssueLinkManager is made for this purpose.

For getting all remote links for the issue:

List<RemoteIssueLink> remoteIssueLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issueId);

 For creating new remote issue link:

remoteIssueLinkManager.createRemoteIssueLink(remoteIssueLink, applicationUser);

 

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 27, 2020

Hi James,

I understand that you're using the JRJC and trying to get back these weblinks in the results.  The reason this is not working is because the REST endpoint you're calling, GET /rest/api/2/issueLink/{linkId}, only is expected to return other Jira issues on this same Jira site.

In this case, in order to get back these weblinks you actually want to be calling a different REST API endpoint, specifically GET /rest/api/2/issue/{issueIdOrKey}/remotelink.  These remote links can be to specific URLs, which typically issue links technically don't do.  You can also create a remote issue link by using the endpoint POST /rest/api/2/issue/{issueIdOrKey}/remotelink.

I hope this helps.

Cheers,

Andy

James Bostock February 9, 2020

Hi Andy,

My apologies for not responding sooner - I have been away on annual leave.

As far as I can tell, the JRJC does not support the remotelink endpoint. For this reason, I ended up rolling my own basic Java client (as I only needed to access two endpoints, this did not require too much effort).

Thanks,

James

Suggest an answer

Log in or Sign up to answer