Create DropDown list for jira custom field in REST API

Viewed 521

I'm trying to retrieve the available options for fields through the Jira REST API but I'm getting stuck on the custom fields.

A normal field returns something like this:

{[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"
  }
}]}

The custom fields on the other hand return a much "smaller" set!

"Sprint" Custom Field:

 {[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"
  ]
}]}

As you can see there are no options available, but i know that there are. How can I get to these values through rest?

I have tried checking the request that the cloud server makes but it's pretty different for each of the custom fields and i cannot find a relation between them. For example:

To get the sprint possible values: https://inn-inw.atlassian.net/rest/greenhopper/1.0/sprint/picker?query=

and to get the Epic values: https://inn-inw.atlassian.net/rest/greenhopper/1.0/epics

I'm trying to make things as clean as possible and I would prefer not to hard code the request, specially because i would probably need to update the code every time a new custom field is created.

PS: I have tried some of the solutions presented in other questions but couldn't find one that fits what i need. eg: https://inn-inw.atlassian.net//rest/api/2/issue/createmeta?projectKeys=PROJKEY&issuetypeNames=Bug&expand=projects.issuetypes.fields returns only the short description that is displayed above.

0 Answers
Related