I am trying to add a comment in JIRA issue using javascript. But its not working. Can someone help me fix this?
<!doctype html>
<html>
<script type="text/javascript">
var usr = 'user1';
var psw = 'pass1';
var sendComment = {"body" : "comment1"};
$("button").on("click",function(){
$.ajax({
type: "POST",
url: "https://xxxxx.atlassian.net/rest/api/2/issue/KEY-123/comment",
dataType: "JSON",
headers: {"Authorization": "Basic " + btoa(usr + ":" + psw)},
data: JSON.stringify(sendComment),
success: function(result) {console.log('success');},
error: function(req, status, err) {console.log('Something went wrong', status, err);}
});
});
</script>
<button>Update JIRA</button>
<body>
</body>
</html>