Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jira REST API: create issue linked to another one

I'd like to link an issue to an existing one at creation using the REST API. The idea is not to CREATE then UPDATE, but just CREATE.

Here is my JSON:

{
    "issueUpdates": [
        {
            "fields": {
                "project": {
                    "key": "CMDB"
                },
                "issuetype": {
                    "id": "10500"
                },
                "summary": "VMP-MYSQL-01",
                "issuelinks": [
                    {
                        "type": {
                            "name": "Relates",
                            "inward": "relates to",
                            "outward": "relates to"
                        },
                        "inwardIssue": {
                            "key": "CMDB-825"
                        },
                        "outwardIssue": "CMDB-825"
                    }
                ],
                "customfield_10600": "VMP-MYSQL-01"
            }
        }
    ]
}

The error I get is:

{
    "issues": [],
    "errors": [
        {
            "status": 400,
            "elementErrors": {
                "errorMessages": [],
                "errors": {
                    "issuelinks": "Field does not support update 'issuelinks'"
                }
            },
            "failedElementNumber": 0
        }
    ]
}

Does the API support the creation of Linked Issue at creation? Using the GUI works.

Jira is running v6.2.

like image 523
Jérémy Avatar asked Sep 23 '14 09:09

Jérémy


People also ask

How do I find linked issues in Jira API?

To obtain the ID of the issue link, use https://your-domain.atlassian.net/rest/api/3/issue/[linked issue key]? fields=issuelinks . If the link request duplicates a link, the response indicates that the issue link was created. If the request included a comment, the comment is added.

How do I enable issue linking in Jira?

Navigate to the Jira Software admin panel using the icon in the upper right and select Issues. In the left hand sidebar, select Issue linking under Issue features. Make sure that Issue linking is set to ON. If it's not, select Activate to enable it.


1 Answers

Since this question is a bit older, I've been experiencing same issue as you. After some searching I found that instead of fields you can use update in the json you send to server.

Alternatively, you can use issueLink method to add links after creating the issue.

Complete code to create an issue with a link to a different issue:

{
  "fields": {
    "summary": "Sample Issue",
    "project": {
      "id": 14505
    },
    "issuetype": {
      "id": 11002
    }
  },
  "update": {
    "issuelinks": [
      {
        "add": {
          "type": {
            "name": "Relates"
          },
          "inwardIssue": {
            "key": "PRJ-1"
          }
        }
      }
    ]
  }
}
like image 75
CraZ Avatar answered Oct 12 '22 23:10

CraZ