在REST API中为jira自定义字段创建DropDown列表

时间:2017-06-01 14:18:09

标签: c# .net rest jira

我正在尝试通过Jira REST API检索字段的可用选项,但我已经卡在自定义字段上。

普通字段返回如下内容:

{[priority, {
  "required": false,
  "schema": {
    "type": "priority",
    "system": "priority"
  },
  "name": "Priority",
  "key": "priority",
  "hasDefaultValue": true,
  "operations": [
    "set"
  ],
  "allowedValues": [
    {
      "self": "https://inn-inw.atlassian.net/rest/api/2/priority/1",
      "iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/highest.svg",
      "name": "Highest",
      "id": "1"
    },
    {
      "self": "https://inn-inw.atlassian.net/rest/api/2/priority/2",
      "iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/high.svg",
      "name": "High",
      "id": "2"
    },
    {
      "self": "https://inn-inw.atlassian.net/rest/api/2/priority/3",
      "iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/medium.svg",
      "name": "Medium",
      "id": "3"
    },
    {
      "self": "https://inn-inw.atlassian.net/rest/api/2/priority/4",
      "iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/low.svg",
      "name": "Low",
      "id": "4"
    },
    {
      "self": "https://inn-inw.atlassian.net/rest/api/2/priority/5",
      "iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/lowest.svg",
      "name": "Lowest",
      "id": "5"
    }
  ],
  "defaultValue": {
    "self": "https://inn-inw.atlassian.net/rest/api/2/priority/3",
    "iconUrl": "https://inn-inw.atlassian.net/images/icons/priorities/medium.svg",
    "name": "Medium",
    "id": "3"
  }
}]}

另一方面,自定义字段会返回一个“更小”的集合!

“Sprint”自定义字段:

 {[customfield_10113, {
      "required": false,
      "schema": {
        "type": "array",
        "items": "string",
        "custom": "com.pyxis.greenhopper.jira:gh-sprint",
        "customId": 10113
      },
      "name": "Sprint",
      "key": "customfield_10113",
      "hasDefaultValue": false,
      "operations": [
        "set"
      ]
    }]}

“Epic Link”

{[customfield_10006, {
  "required": false,
  "schema": {
    "type": "any",
    "custom": "com.pyxis.greenhopper.jira:gh-epic-link",
    "customId": 10006
  },
  "name": "Epic Link",
  "key": "customfield_10006",
  "hasDefaultValue": false,
  "operations": [
    "set"
  ]
}]}

正如您所看到的,没有可用的选项,但我知道有。 如何通过休息来获得这些价值?

我已经尝试检查云服务器发出的请求,但是每个自定义字段的请求都不同,我找不到它们之间的关系。例如:

要获得sprint可能的值:https://inn-inw.atlassian.net/rest/greenhopper/1.0/sprint/picker?query=

并获取Epic值:https://inn-inw.atlassian.net/rest/greenhopper/1.0/epics

我正在努力使事情尽可能干净,我宁愿不对请求进行硬编码,特别是因为我可能需要在每次创建新的自定义字段时更新代码。

PS:我已经尝试了其他问题中提出的一些解决方案,但找不到符合我需要的解决方案。例如:https://inn-inw.atlassian.net//rest/api/2/issue/createmeta?projectKeys=PROJKEY&issuetypeNames=Bug&expand=projects.issuetypes.fields仅返回上面显示的简短描述。

0 个答案:

没有答案