How to get possible options for a custom "label" field via the REST API (v2 or v3)?

Setup:

I created a custom field with “Labels” via the Jira UI:

Motivation:

I want to access all available options for this label from within a forge app, using the Rest API v2/ v3 (to create a custom issue-creation dialog in our application).

Problem:

  • First, I call /rest/api/3/issue/createmeta/${projectIdOrKey}/issuetypes/${issueTypeId} to obtain the create-issue metadata (containing the customField)

  • In the response, the custom field yields the autoCompleteUrl:"https://api.atlassian.com/ex/jira/.../rest/api/1.0/labels/suggest?" - But when trying to call this endpoint from my forge-app, I always get a { code: 401, message: 'Unauthorized; scope does not match' }

Question (or what I’ve tried so far):

Is there a v2/v3 equivalent for “https://api.atlassian.com/ex/jira/.../rest/api/1.0/labels/suggest”?

I’ve tried:

  • /rest/api/3/labelonly yields the system-labels

  • /rest/api/3/field/{fieldId}/context/{contextId}/optionyields: errorMessages: [ “The custom field doesn’t support options.” ])

Hello @JulianGtze

Labels fields do not contain options, they contain labels. Only fields such as Select or Multi Select have options that can be set, read or deleted via the REST API

The API endpoint you need to use is the Get field autocomplete suggestions endpoint, like this:

/rest/api/3/jql/autocompletedata/suggestions?fieldName={FieldName}

That will return the set of labels in that custom Labels field.

BUT… be warned, the autocomplete suggestions returned is not always the complete set! It is often a subset of the complete set, as you’re dealing with something the GUI is going to display. Then you have start using predicators to the search. This is a known limit of using this method to get the ‘options’ or ‘values’ for a particular field.

2 Likes