Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create an issue with Rest Apis?

Devi Foskett January 28, 2019

I would like to be able to create a Jira sub-task issue through a google extension. I would like to keep it to javascript. Here is what I have so far.

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);
};
}

Sorry about the bad formatting, but it will not keep my formatting set. Anyway, I would like to be able to have a user select the "scYes" button and it should create a subtask under the project TENX-409.  

0 answers

Suggest an answer

Log in or Sign up to answer