Hi there,
I’m currently exploring the Bulk Edit Issue APIs from Jira Cloud REST APIs to update issue labels. My goal is to replace a specific label with a new label, but I’ve encountered some limitations.
Using the REPLACE
operation replaces all existing labels with the provided new label, which is not ideal for this use case. I’ve also tried combining REMOVE
and ADD
operations as a workaround, but this approach doesn’t seem to work as expected.
Here are the code snippets for reference:
Attempt 1: Using REPLACE
const bodyData = {
sendBulkNotification: false,
selectedIssueIdsOrKeys: issues.map(issue => issue.key),
selectedActions: ["labels"],
editedFieldsInput: {
labelsFields: [
{
bulkEditMultiSelectFieldOption: "REPLACE",
fieldId: "labels",
labels: [
{
name: currentLabel?.name
}
]
},
]
}
};
const res = await requestJira(`/rest/api/3/bulk/issues/fields/`, {
method: "POST",
body: JSON.stringify(bodyData),
headers: {
"content-Type": "application/json",
Accept: "application/json"
}
});
const jsonRes = await handleJiraResponse(res);
console.log("jsonRes", jsonRes);
Attempt 2: Combining REMOVE
and ADD
const bodyData = {
sendBulkNotification: false,
selectedIssueIdsOrKeys: issues.map(issue => issue.key),
selectedActions: ["labels"],
editedFieldsInput: {
labelsFields: [
{
bulkEditMultiSelectFieldOption: "REMOVE",
fieldId: "labels",
labels: [
{
name: currentLabel?.name
}
]
},
{
bulkEditMultiSelectFieldOption: "ADD",
fieldId: "labels",
labels: [
{
name: newLabel
}
]
}
]
}
};
const res = await requestJira(`/rest/api/3/bulk/issues/fields/`, {
method: "POST",
body: JSON.stringify(bodyData),
headers: {
"content-Type": "application/json",
Accept: "application/json"
}
});
const jsonRes = await handleJiraResponse(res);
console.log("jsonRes", jsonRes);
Both attempts haven’t yielded the desired result. Is there a recommended way to replace only a specific label without affecting the others? Alternatively, is this functionality planned for future updates, or am I missing something in the API documentation?
Any insights or suggestions would be greatly appreciated!