GET Values from a custom field via JIRA REST API

风流意气都作罢 提交于 2019-12-07 05:36:17

问题


I would like to GET all drop down options for a custom field. For system fields, I use the following URI:

http://localhost:8080/rest/api/2/project/XXXX/components

(for components, versons, etc. Basically system fields), so I tried the following for a custom field

http://localhost:8080/rest/api/2/project/XXXX/customfield_10000

and got a 404 error. I'm not sure what I'm doing wrong as I've been googling for the past 19 hours. The best I search result I got was the following documentation: JIRA Developers Documentation

Please assist, I'm not sure What I'm missing


回答1:


You can get that information either from the createmeta or editmeta REST resources.

Use editmeta if you want to retrieve the available options when editing a specific issue. E.g.

GET /rest/api/2/issue/TEST-123/editmeta

Use createmeta when you want to retrieve the options for a project in combination with an issue type. E.g.

GET /rest/api/2/issue/createmeta?projectKeys=MYPROJ&issuetypeNames=Bug&expand=projects.issuetypes.fields

The customfields with options will be returned like this:

"customfield_12345": {
  "schema": {
    "type": "string",
    "custom": "com.atlassian.jira.plugin.system.customfieldtypes:select",
    "customId": 12345
  },
  "name": "MySelectList",
  "allowedValues": [
    {
      "self": "http://jira.url/rest/api/2/customFieldOption/14387",
      "value": "Green",
      "id": "14387"
    },
    {
      "self": "http://jira.url/rest/api/2/customFieldOption/14384",
      "value": "Blue",
      "id": "14384"
    }
  ]
}


来源:https://stackoverflow.com/questions/37984491/get-values-from-a-custom-field-via-jira-rest-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!