I want to create an issue in JIRA via REST API call in javaScript code.. When I executed the below code there is no error, but also no issue is created in JIRA. I have used the same JSON code to create issue in JIRA with "CURL" command. But I failed to create with this sample code below.Can anyone please help on this. Note: consider credentials and URL is correct.
<html>
<head>
<meta charset="ISO-8859-1">
<title>Create Issue</title>
<script type="text/javascript">
function createIssue() {
var xhttp = new XMLHttpRequest();
var createJson ='{ "fields": {
"project":{
"key": "LPS"
},
"summary": "creting issue",
"description": "creating issue from client isde",
"issuetype": {
"id": "10000"
},
"priority": {
"id": "2"
},
"assignee":{
"name": "abcd"
}
}
}';
xhttp.onreadystatechange = function() {
if ((xhttp.readyState==4) {
document.getElementById("demo").innerHTML =xhttp.responseText;
}
};
xhttp.open("POST", "URL",true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.setRequestHeader("X-Atlassian-Token", "nocheck");
xhttp.setRequestHeader('Authorization', 'Basic'+btoa('username:password'));
xhttp.send(createJson);
}
</script>
</head>
<body>
<h2>Create Issue</h2>
<button type="button" onclick="createIssue()">createIssue</button>
<p id="demo"> </p>
</body>
</html>
Regards, Kavitha