I am trying to create a subtask issue creator extension. This extension should use javascript and json to create an issue when the user has clicked the button "scYes" and to just simply add labels when "scNo" is chosen.
Javascript
window.onload = function(){
document.getElementById('scYes').onclick = function() {
var project = "TENX-409"
var xhr = new XMLHttpRequest(),
method = "POST",
url = "https://jira2dev.cerner.com/rest/api/2/issue/";
var json;
xhr.open(method, url, true);
xhr.setRequestHeader("Content-Type","application/javascript");
json = JSON.parse(' {"fields": { "project": { "key": "TENX" }, "parent": { "key": "' + project + '" }, "summary": "Sub-task of TENX-409 TEST Extension", "description": "TEST", "issuetype": { "id": "5"} } } ');
console.log(json);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
xhr.send();
};
}
document.getElementById('scNo').onclick = function(){
var test = ' "labels" :["Reviewed", "Technical"] ';
var myObj = JSON.parse(test);
};
}
You seem to be missing the json that tells it what issue type it is
"issuetype": {"name": "Sub-task"}
or whatever type you use as a sub-task
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.