【发布时间】:2018-03-07 17:32:10
【问题描述】:
我想通过 javaScript 代码中的 REST API 调用在 JIRA 中创建一个问题。当我执行以下代码时没有错误,但在 JIRA 中也没有创建问题。我使用相同的 JSON 代码通过“CURL”命令在 JIRA 中创建问题。但我未能使用下面的示例代码创建。任何人都可以帮助解决这个问题。 注意:考虑凭据和 URL 是否正确。
<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>
问候, 卡维莎
【问题讨论】:
标签: javascript json jira-rest-api