jira REST API 创建问题(包括组件)

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

我正在尝试使用 Jira REST API(包括组件)创建问题。我正在发布此 JSON,但我收到远程服务器返回错误:(400) 错误请求。

问题是:-没有组件就没有错误,但是当组件存在时就会产生问题。有什么帮助吗? JSON:

{
  "fields": {
    "project": {
      "key": "keyGoesHere"
    },
    "assignee": {
      "name": "name.surname"
    },
    "component": {
      "name": "someName"
    },
    "summary": "test2",
    "description": "test2",
    "issuetype": {
      "name": "Task"
    }
  }
}
components jira jira-rest-api bad-request
2个回答
18
投票

我找到了答案。以防万一有人需要。

"components": [{
  "name": "someName"
}],

0
投票

一个使用 扩展创建 jira 问题的完整工作示例:两个选项可能会有所不同

  • 网址路径
    /<-option-jira>/
    可能不存在
  • 自定义字段编号来自
    customfield_10228
### Create Issue as Test with steps the option-jira may be NULL in your setup
POST https://exmple.com/<-option-jira>/rest/api/2/issue/
Authorization: Bearer <your_token>
Content-Type: application/json

{
  "fields": {
    "project": { "key": "XAMPL" },
    "summary": "Create Jira Issue per REST",
    "components": [{"name": "Xampl"}],
    "description": "Creating issue with project key & issue type 
                    using the REST API",
    "issuetype": { "name": "Test" },
    "customfield_10228":{
      "steps":[
        { "index":1,  
          "fields":{ "action":"Step 1", 
                     "data":"input Data 1", 
                     "expected result":"Excepted result 1"} },
        { "index":2, 
          "fields":{ "action":"Step 2", 
                     "data":"input Data 2", 
                     "expected result":"Excepted result 2" } },
        { "index":3, 
          "fields":{ "action":"Step 4", 
                     "data":"input Data 3", 
                     "expected result":"Excepted result 3" } }
      ]
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.