Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to add issuelinks in rest api ?

Hi everyone,

I followed this article :
https://confluence.atlassian.com/jirakb/how-to-use-rest-api-to-add-issue-links-in-jira-issues-939932271.html

But it doesn't work.

Here is my request :

{
"fields":{
"project":{
"key":"XX"
},
"summary":"test bug summary",
"description":"test bug description",
"issuetype":
{"id":"XXXXX"}
},
"update":{
"issuelinks":[
{
"add":{
"type":{
"name":"Blocks",
"inward":"is blocked by",
"outward":"blocks"
},
"outwardIssue":{
"key":"XX-967"
}
}
}
]
}
}

Can you please help me ?

1 answer

0 votes

Hello,

Thanks for reaching out and fist it looks like you are Looking at the Jira Server Docs for the API formatting but your account is tied to a Jira Cloud address, The Formatting you are using for the data portion is for Jira Server and should be working without issue on a POST api/2/issue

If you are on Jira Server and this is failing what is the full syntax of the call you're using, and what is the Response error message you are getting when the call is failing?

For Jira Cloud:

The Documentation for the API can be found here:

There are a few changes needed for the call on the cloud side, You will want to use the version 3 endpoint for issue and do a POST /rest/api/3/issue

Then there is some additional formatting requirement on the Description where you currently have is set as "description":"test bug description", it should be formatted as follows:

    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "text": "test bug description",
              "type": "text"
            }
          ]
        }
      ]
    },

So the Full data portion should look like this:

{
   "fields":{
      "project":{
         "key":"XX"
      },
      "summary":"test bug summary",
      "description": {
          "type": "doc",
          "version": 1,
          "content": [
            {
              "type": "paragraph",
              "content": [
                {
                  "type": "text",
                  "text": "test bug description"
                }
              ]
            }
          ]
        },
      "issuetype":{
         "name":"Bug"
      },
      "priority":{
         "name":"Major"
      }
   },
   "update":{
      "issuelinks":[
         {
            "add":{
               "type":{
                  "name":"Blocks",
                  "inward":"is blocked by",
                  "outward":"blocks"
               },
               "outwardIssue":{
                  "key":"XX-967"
               }
            }
         }
      ]
   }
}

Regards,
Earl

Hi Earl, thank you for your answer. You're right, I'm on Jira Cloud sorry. I tried with your answer but I still have the same problem on api/3 or api/2

{
"fields":{
"project":{
"key":"RD"
},
"summary":"test bug summary",
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "test bug description"
}
]
}
]
},
"issuetype":
{"id":"XXXX"}
},
"update":{
"issuelinks":[
{
"add":{
"type":{
"name":"Blocks",
"inward":"is blocked by",
"outward":"blocks"
},
"outwardIssue":{
"key":"XX-967"
}
}
}
]
}
}

Curl :

 


curl -X POST \
https://XXXXX.atlassian.net/rest/api/2/issue \
-H 'Authorization: Basic XXXXXXXXXXXXX' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"fields":{
"project":{
"key":"XX"
},
"summary":"test bug summary",
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "test bug description"
}
]
}
]
},
"issuetype":
{"id":"XXXX"}
},
"update":{
"issuelinks":[
{
"add":{
"type":{
"name":"Blocks",
"inward":"is blocked by",
"outward":"blocks"
},
"outwardIssue":{
"key":"XX-967"
}
}
}
]
}
}'

 

And the API send me this error :

 

{
"errorMessages": [],
"errors": {
"issuelinks": "Field 'issuelinks' cannot be set. It is not on the appropriate screen, or unknown."
}
}

Hey there,

The formatting looks good but the error you are encountering is related to the field:

"Field 'issuelinks' cannot be set. It is not on the appropriate screen, or unknown."

The noted field "issuelinks" is going to be the "Linked Issues" field on the system front end,  And it is either missing from the Create screen of the inward links project or the Edit Screen of the outward links project. 

Regards,
Earl

Hi, I have exactly same scenario. But my case the field is already there in on the screen.

Still getting below error :

 

"Field with id' issuelinks' and name 'Linked Issues' does not support operation 'outwardIssue' Supported operation(s) are: 'add'"

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,469 views 22 32
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you