使用REST API更新JIRA票证状态

问题描述 投票:4回答:2

我可以使用CURL命令在JIRA中创建票证,并且可以方便地使用json数据。

curl -D- -u:-X POST --data @ -H“内容类型:application / json” http:// : / rest / api / 2 / issue /

我现在正在尝试更新所生成票证的状态,但出现以下错误。{"errorMessages":[],"errors":{"status":"Field 'status' cannot be set. It is not on the appropriate screen, or unknown."}}

卷曲命令:

curl -D- -u : -X PUT --data @ data_update.txt -H“内容类型:application / json”http:// :8100 / rest / api / 2 / issue / MTF-3

curl jira jira-rest-api jira-rest-java-api
2个回答
7
投票

状态不是Jira中的一个字段,因此无法即时更改该字段。 JIRA API对此没有规定。

我们必须遵循过渡并相应地进行更改。

首先,执行'http://localhost:8100/rest/api/latest/issue/MTF -2 / transitions?expand = transitions.fields并知道该ID用于过渡。

例如:“停止进度”的过渡ID为31,“完成”的过渡ID为41。

一旦知道,通过添加与您的环境有关的值来使用以下链接:

curl -D- -u <USER>:<PASS> -X POST --data '{"transition":{"id":"<TRANSITION_ID>"}}' -H "Content-Type: application/json" <JIRA_URL>:<JIRA_PORT>/rest/api/latest/issue/<JIRA_ISSUE>/transitions?expand=transitions.fields

参考:选中Paul Grants答案-https://answers.atlassian.com/questions/107630/jira-how-to-change-issue-status-via-rest


0
投票

这对我很有效,因为长期使用R。类似的方法应该可以用于'httr'库使用的curl。

library(httr)
library(RJSONIO)

x <- list(fields = list(project = c(key = "xxxxxxx"), 
                        status = "Assign",
                        issuetype = c(name = "xxxx"),
                        summary = "xxxxxxx",
                        description = "xxxxxxx",
                        customfield_xxxxxx = c(value = "xxxxxx"),
                        assignee = c(name = "userid"),
                        customfield_xxxxxx = "xxxxxxxx"
            ))

# can add more fields as shown above

response <- POST("https://xxxxxxx.atlassian.net/rest/api/2/issue/",body = toJSON(x), 
                  authenticate(username,passcode, "basic"), 
                  add_headers("Content-Type" = "application/json"), 
                  verbose()
                 )
© www.soinside.com 2019 - 2024. All rights reserved.