JIRA Rest API 使用 JSON 关闭问题

JIRA Rest API Close Issue Using JSON

我正在尝试编写一种允许用户使用 json 关闭 JIRA 问题的方法。 这是我正在使用的 url:

../jira/rest/api/latest/issue/MyProj-524/transitions

这是我的 json 字符串:

 { "update" : {"comment": [{"add": {"body":"Fixed"}}]}, "fields" : { "resolution" : {"id":"10000","name":"Done" }}, transition": {"id": "6"}}

我收到 400 异常(错误请求)和 ProtocolError 状态。根据文档,如果没有指定转换,将返回 400。

此外,当我使用
从浏览器查询 JIRA 服务器时 ..:8090/jira/rest/api/latest/issue/MyProj-524/transitions 我得到以下信息:

 {"expand":"transitions","transitions":[{"id":"5","name":"Resolve Issue","to":{"self":"/jira/rest/api/2/status/5","description":"A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.","iconUrl":"..8090/jira/images/icons/statuses/resolved.png","name":"Resolved","id":"5","statusCategory":{"self":"...8090/jira/rest/api/2/statuscategory/3","id":3,"key":"done","colorName":"green","name":"Done"}}},{"id":"2","name":"Close Issue","to":{"self":".:8090/jira/rest/api/2/status/6","description":"The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.","iconUrl":"..8090/jira/images/icons/statuses/closed.png","name":"Closed","id":"6","statusCategory":{"self":"8090/jira/rest/api/2/statuscategory/3","id":3,"key":"done","colorName":"green","name":"Done"}}}]}

看来有可用的转换。我们使用的 "Classic Default Workflow" 包含:Open、Resolved、Closed、Reopened 和 In Progress。工单当前状态为:未结。

您确定使用了正确的转场 ID 吗?你查对了吗

.../jira/rest/api/latest/issue/MyProj-524/transitions?展开=transition.fields

您的 ID 应与您要转换成的过渡相匹配。在我的例子中(使用 Jira 云附带的标准转换,我的 ID 是 31(对于 "Done")

您可能还想确认您的工作流程是否允许将问题从打开状态变为关闭状态。您可以通过“管理”>“问题”>“工作流程”>“分配的方案”>“以图表形式查看”将其视为图表

这里还有一些建议:

https://answers.atlassian.com/questions/86247/how-can-i-close-an-issue-via-a-rest-api-call