Is it possible to delete all labels inside the Custom Field?
Currently i have a put rest request with
{ "update": { "customfield_10258": [ {"remove": "label1"}, {"remove": "label2"}, {"remove": "label3"}, {"add": "lolito"} ] } }
Is there a way to remove all existing labels inside the Custom Field (type labels) without specifying label1, label2, label3,.....?
I just started a discussion about this crazy JSON stuff and decided to drop the link here since it focuses on Labels.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Labels in JIRA won't actually disappear from the system until all issues in JIRA are updated to remove that specific label. So we can't directly delete a label without first updating all the issues that have that label to remove it from those issues.
This can be done over the REST API, but you first have to identify all the issues that have this specific label. You can do this with either the issue navigator or the REST endpoint /api/2/search
In my example I created a label called "test1". So using that search endpoint I specified the jql parameter of
labels=test1
That will return all the issueid and key of the issues that use this label. You would need to know all these so you can then update them in the next step.
Once you have all these, you can see how to edit issues using REST in the api/2/issue documentation
/api/2/issue/{issueIdOrKey} endpoint let's us do that. Specify the issueid or the issue key and then you can use a json format such as:
{"update":{"labels":[{"remove":"test1"}]}}
This will remove the label from that specific issue.
If you repeat that issue update for all the issues with this label until you have no results in the search, then that label has been removed from the system.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For search:
https://YourInstance.atlassian.net/rest/api/2/search?jql=labels=YourLabel&fields=labels
For add/remove label, test with Postman
Method: PUT
URL: https://YourInstance.atlassian.net/rest/api/2/issue/KEY-1
Authorization: Type = Basic. Enter your Username/Password
Headers:
Key = Content-Type
Value = application/json
Body: raw
{"update" : {"labels" : [{"add" : "add-new-label"}, {"remove" : "remove-label"}]}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.