GET Values from a custom field via JIRA REST API

2019-06-23 16:30发布

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

标签: rest jira
1条回答
Rolldiameter
2楼-- · 2019-06-23 17:30

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"
    }
  ]
}
查看更多
登录 后发表回答