I would like to be able to add labels to a Jira using rest apis. I am using javascript currently to create an issue. I do not know the json required to create the label and need help figuring that out. I use only javascript and json for this thank you! When using postman there is a 415 error when I add "Labels":["Test"] to create a label.
Javascript:
var xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.setRequestHeader("Content-Type","application/json");
labels = ' {"fields": { "project": { "key": "'+ projectKey +'" }, "labels":["sd_reviewed", "ta_reviewed", "Reviewed", "Functional"]}} ';
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
};
xhr.send(labels);