过渡问题时,JIRA REST API是否需要提交过渡ID? [英] Does the JIRA REST API require submitting a transition ID when transitioning an issue?

查看:323
本文介绍了过渡问题时,JIRA REST API是否需要提交过渡ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我发布这样的问题过渡:

If I POST an issue transition like this:

{
    "fields" : {
        "resolution" : {
            "name" : "Fixed"
        }
    }
}

...我收到此错误:

...I get this error:

{
    "errorMessages" : ["Missing 'transition' identifier"],
    "errors" : {}
}

这似乎暗示我需要在我的已更改字段列表中包括一个过渡ID. https://stackoverflow.com/a/14642966/565869 似乎是一样的.好吧.

This seems to imply that I need to include a transition ID along with my list of changed fields. https://stackoverflow.com/a/14642966/565869 seems to say the same. Fine.

但是,过渡ID似乎是全局的.查找此问题的最高转换ID并递增它是不够的.这样的ID可能已在其他地方使用.付出一定的代价,我可以获得系统中任何地方使用的最高交易ID.目前可能是68,000.但是,如果我当时要使用交易ID 68,001,则GUI用户很有可能会尝试自己转换并使用此ID.

However, transition IDs appear to be global. It's not enough to look up the highest transition ID for this issue and increment it; such an ID is probably in use elsewhere. At some expense, I could get the highest transaction ID used anywhere in the system; this might be 68,000 at this moment. But if I were then to use transaction ID 68,001 there's a real chance that a GUI user would attempt a transition of their own and use this ID before I could.

我可以使用1,000,001以上的交易ID,但是如果JIRA Web GUI在生成新ID时使用以前使用过的最高交易ID,我只会在此范围内发生冲突,而不是在68,000范围内.我可以使用69,000,并相信获得最高交易ID所需的时间不会有千次转换.

I could use transaction IDs in the range of 1,000,001 and up, but if the JIRA web GUI uses the highest previously used transaction ID when generating new IDs I'll just collide in this range instead of the 68,000 range. I could use 69,000 and trust that there won't be a thousand transitions in the length of time it takes to get the highest transaction ID.

但是,这两者看起来都非常笨拙.有没有办法发布过渡并让JIRA生成自己的唯一ID?我不需要检索生成的ID,我只想更新问题的状态和解决方案.

These both seem terribly clumsy, however. Is there no way to post a transition and let JIRA generate its own unique ID? I don't need to retrieve the generated IDs, I just want to update issues' statuses and resolutions.

推荐答案

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

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.

这更有意义吗?

这篇关于过渡问题时,JIRA REST API是否需要提交过渡ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆