Hi Community,
Please guide on how generate a list of existing labels present in Jira Software (Data Center) via API call.
It will be a great help you could share necessary help document and syntax code to generate the same via API call.
Thanks
In Jira Data Center, there is no native REST API endpoint that directly provides a list of all existing labels. However, there are some alternatives to obtain this information.
You can use the issue search REST API (/rest/api/2/search) and extract the labels from the results.
Endpoint:
/rest/api/2/search?jql=labels IS NOT EMPTY&fields=labels&maxResults=1000
Example of Usage with cURL
curl -u "seu_usuario:seu_token" -X GET \
"https://SEU_JIRA_URL/rest/api/2/search?jql=labels IS NOT EMPTY&fields=labels&maxResults=1000" \
-H "Content-Type: application/json"
I hope this helps you.
Best Regards.
Below is a pseudo code that you could use
Use below jql and narrow it down as much possible say by adding condition like statusCategory != Done
then use below rest end point
url = "https://your-domain.atlassian.net/rest/api/3/search/jql"
headers = {
"Accept": "application/json"
}
auth = HTTPBasicAuth("email@example.com", "<api_token>")
query = {
'jql': 'labels is not EMPTY',
'maxResults': 100,
'fields': '[key, labels]'
}
response = requests.request(
"GET",
url,
headers=headers,
params=query,
auth=auth
)
and then loop based on nextPageToken
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.