且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

过渡问题时,JIRA REST API是否需要提交过渡ID?

更新时间:2022-03-17 09:46:33

您有点困惑.因此,让我看看是否可以为您更好地解释它.

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

要过渡JIRA问题,请使用过渡ID标识要应用于该问题的过渡.您没有指定交易的ID或过渡ID来标识发生了过渡,JIRA会为您处理.

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.

因此,首先,您可以通过对API调用进行GET来查看对Issue可用的过渡:

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

示例:

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

将显示以下内容:

{
    "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"
            }
        }
    ]
}

因此您可以看到对于发行版ABC-123仅提供1个转换,并且其ID为161.

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

如果要通过GUI浏览到该JIRA发行版,则只会看到1个可用的转换,并且它将与API调用相匹配.实际上,如果您检查了元素,则应该看到它具有a标签,并且在href中有类似action=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

因此,如果您想过渡此问题,则需要对以下URL进行POST:

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

使用这样的JSON:

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

使用从显示所有转换的呼叫中找到的转换ID.我还更新了决议和受让人,并同时添加了评论.

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.

这更有意义吗?