Receiving Error 400 - Bad Request when using REST API to manage Labels
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When using REST API /rest/api/2/issue/<issue-id> to add or remove labels, the request fails with Error 400 - Bad Request:
JSON using Fields:
1
2
3
4
5
6
7
8
9
10
11
12
{
"fields": {
"project": {
"id": "10000"
},
"summary": "something's wrong",
"labels": [
"bugfix",
"blitz_test"
]
}
}
JSON using update:
1
2
3
4
5
6
7
8
9
10
11
12
{
"update": {
"labels": [
{
"add": "newlabel1"
},
{
"remove": "bugfix"
}
]
}
}
Diagnosis
The Labels fiels should be editable when creating or editing the issue.
Cause
Using REST/API, it is only possible to update/edit a field in an issue if it is part of the edit screen for that project/issuetype.
Although Labels can be edited in the view issue page, using the inline-edit small pencil, it only considers if the user has EDIT_ISSUE permission, not whether the "labels" field is on the edit screen config.
Reference: JRASERVER-27936 - Add ability to use setSkipScreenCheck() when updating an issue via REST.
Solution
Add the "labels" field to create/edit screens.
Was this helpful?