Hi,
I want to create an issue in JIRA via REST API call with 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 and it worked succesfully. 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": {
"name": "Task"
},
"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>
What do you mean that there is no error? Do you get 200 status code? If there is no error then you should get the key of the created issue.
Hey, Am not getting any response from the server and the issue is not getting created in JIRA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you make a request to a server then you must get a response. Try to use Developer Tools in your browser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
not sure why its not responding and i could add the comment and edit the existing fields of an issue with the same sample code but only this one(creating issue) is not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share the updated code. Am also trying to update JIRA issues using javascript..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.