Does the JIRA REST API require submitting a transition ID when transitioning an issue?

回眸只為那壹抹淺笑 提交于 2019-12-04 06:37:18

You're getting mixed up a bit. So lets see if I can explain it better for you.

To transition a JIRA Issue, you use the Transition ID to identify what transition to apply to the issue. You aren't specifying an ID for a transaction or a transition ID to identify that the transition occurred, JIRA takes care of this for you.

The easiest way to understand it is to see it.

So first you can look at what transitions are available to an Issue by doing a GET to the API Call:

/rest/api/2/issue/${issueIdOrKey}/transitions

Example:

/rest/api/2/issue/ABC-123/transitions

Which will show something like this:

{
    "expand": "transitions",
    "transitions": [
        {
            "id": "161",
            "name": "Resolve",
            "to": {
                "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.",
                "iconUrl": "https://localhost:8080/images/icons/statuses/resolved.png",
                "id": "5",
                "name": "Resolved",
                "self": "https://localhost:8080/rest/api/2/status/5"
            }
        }
    ]
}

So you can see only 1 transition is available for issue ABC-123 and it has an ID of 161.

If you were to browse to that JIRA Issue through the GUI, you would see only 1 Transition available and it would match the API Call. In fact if you inspected the element you should see it having an a tag and in the href something like action=161

So should you want to transition this issue, you'll need to do a POST to the following URL:

/rest/api/2/issue/ABC-123/transitions

With JSON like this:

{
    "update": {
        "comment": [
            {
                "add": {
                    "body": "Bug has been fixed."
                }
            }
        ]
    },
    "fields": {
        "assignee": {
            "name": "bob"
        },
        "resolution": {
            "name": "Fixed"
        }
    },
    "transition": {
        "id": "161"
    }
}

Which uses the transition ID found from the call that shows all transitions. I also update the resolution and assignee and add comments at the same time.

That make a bit more sense?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!