Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a Relate to link between issues in different Jira sites VIA REST API

Taiseer Hussein
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 12, 2019

We  have multiple Jira sites in our company, each one has its own purposes. Is there a way to link issues together between these sites using the REST API.  

This is our scenario 

https://domain.mycompany.com/jira01/browse/PROJ-123

https://domain.mycompany.com/jira02/browse/QA-510. 

Now I would like to use the REST API to link these two issues together VIA REST API.  

Thanks a lot. 

1 answer

0 votes
Rafael Pinto Sperafico
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2019

Hi @Taiseer Hussein,

It seems there is no REST API endpoint for such a request.

However, you can accomplish the PROJ-123 >> More >> Link >> Jira Issue by following the steps below:

Application Link ID

Find out what is the Application Link ID your current source Jira instance (jira01) will be communicating to (jira02). To do it so:

As a response, you should find jira02 information:

{
"list": [
{
"application": {
"id": "5b8f5fb7-bf2a-3200-aa94-82793ffda887",
"typeId": "jira",
"name": "jira02",
"displayUrl": "https://domain.mycompany.com/jira02",
...
"rpcUrl": "https://domain.mycompany.com/jira02",

Take note of the "id" value, in the example above 5b8f5fb7-bf2a-3200-aa94-82793ffda887.

Issue ID

Find out the Jira issue ID from jira01

You can do that by hitting the following URL from you web browser https://domain.mycompany.com/jira01/rest/api/2/issue/PROJ-123

It will be the first "id" in response from endpoint above (in my example, 10100)

Creating Related to issue link

Now that you have gathered the necessary information build the payload, let's review what the payload is about:

inline=true
id=10100
jiraAppId=9f2d636e-c842-3388-8a66-17c1b951dd45
linkDesc=relates+to
issueKeys=QA-510
createReciprocal=true
comment=testing+relates+to+link
commentLevel=

 Above is what you will be passing to the endpoint:

  • id, relates to the Jira issue id in jira01 for PROJ-123
  • jiraAppId, relates to the jira02, so Jira knows against which instance the link should be created
  • linkDesc, this is what your request is about
  • issueKey, the targeted issue in jira02
  • createReciprocal, whether both instances should have a link to one another
  • comment, if there is anything to be said about this linking action

And you should be consuming the following endpoint https://domain.mycompany.com/jira01/secure/LinkJiraIssue.jspa

The cURL command would be:

curl -k -u USERNAME_A \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'X-Atlassian-Token: no-check' \
-H 'X-AUSERNAME: USERNAME_B' \
--data 'inline=true&id=10100&jiraAppId=5b8f5fb7-bf2a-3200-aa94-82793ffda887&linkDesc=relates+to&issueKeys=QA-510&createReciprocal=true&comment=testing+relates+to+link&commentLevel=' --compressed \
-X POST 'https://domain.mycompany.com/jira01/secure/LinkJiraIssue.jspa'
  • USERNAME_A is the user authenticating against jira01
  • USERNAME_B is the user with permissions in jira02

Hope the above helps.

Kind regards,

Rafael

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events