如何通过rest api

时间:2016-03-24 18:36:56

标签: jira jira-rest-api

我希望能够通过Jira API为问题添加标记。我无法找到有关此问题的任何文档。有谁知道这是如何工作的?

3 个答案:

答案 0 :(得分:5)

我已经想出如何做到这一点,我不确定API的版本。我发出POST请求:

yourdomain /rest/greenhopper/1.0/xboard/issue/flag/flag.json

在正文中(用您的问题密钥替换JIRA-ISSUE):

{"issueKeys":["JIRA-ISSUE"],"flag":true}

我希望这会有所帮助。

答案 1 :(得分:2)

这是我找到的最佳答案。 https://answers.atlassian.com/questions/38062844/answers/38062897

有一个名为Flagged的字段。它是一个复选框类型字段。默认情况下,有一个值Impediment。检查该字段是否为空状态。如果该字段为空,则不会标记该问题。如果该字段不为null,则会标记该问题。

您可以使用REST API。示例在这里 -

https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue.

您需要知道字段ID(customfield_10000),或者您需要通过搜索元数据来编写字段的发现脚本 - https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-discovering-meta-data-for-creating-issues

在通过API创建问题时设置自定义字段的示例 -

curl -D- -u fred:fred -X POST --data {"fields":{"project":{"key":  "TEST"}, "summary": "Always do right. This will gratify some people and  astonish the REST.", "description": "Creating an issue while setting custom  field values", "issuetype":{"name": "Bug"}, "customfield_10000": [{"value":  "Impediment"}]}} -H "Content-Type: application/json"    http://localhost:8090/rest/api/2/issue/
non-minified data  Expand source
{
"fields": {
   "project":
   { 
      "key": "TEST"
   },
   "summary": "Always do right. This will gratify some people and astonish the REST.",
   "description": "Creating an issue while setting custom field values",
   "issuetype": {
      "name": "Bug"
   },       
   "customfield_10000": [ {"value": "Impediment" }]       
  }
}

答案 2 :(得分:1)

如上所述here,"已标记"是一个复选框自定义字段,它接受单个值" Impediment"。

您应该能够像使用任何其他自定义字段一样使用JIRA REST API进行设置。也许示例here会有所帮助。

您还可以使用JIRA Java API设置自定义字段值。