JIRA Rest API错误.无法识别的令牌造成了问题 [英] JIRA Rest API error. Unrecognized token creating a issue
问题描述
通过AJAX和REST API添加问题没有运气.不幸的是,我可以将它与Postmen一起使用,而无法通过Ajax请求获得它.
No luck in adding a issue via AJAX and the REST API. I can get it to work with Postmen, unfortunatly, can't get it with an Ajax request.
我创建的JSON很好,发布请求也可以.问题类型是我自己创建的,使用Bug会产生相同的问题.查看创建的JSON对象,我的错误和我的代码: JSON对象(这是console.log的片段):
The JSON I create is fine, the post request also. The issuetype is something I created myself, using Bug gives the same problem. See the JSON object created, my error and my code: JSON object (this is a snippet from console.log):
错误
0:无法识别的令牌'fils5poet5':预期为'null','true', [来源: org.apache.catalina.connector.CoyoteInputStream@7b958ed2;行:1 栏:21]"
0: "Unrecognized token 'fils5poet5': was expecting 'null', 'true', 'false' or NaN↵ at [Source: org.apache.catalina.connector.CoyoteInputStream@7b958ed2; line: 1, column: 21]"
jira = {
fields : {
project : {
key : "CIC"
},
summary : "test",
description: "test",
issuetype : {
name : "Sandbox item"
}
}
};
console.log(jira); //Also see image at top of this post.
// Submit to Jira api
$.ajax({
type : "POST",
dataType : "JSON",
url : configuration.api_url,
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic ItsAWrap!(itworks...)"),
xhr.setRequestHeader ("Content-Type", "application/json");
},
data : jira,
success : (function(response) {
//Do something
}})
推荐答案
您可以尝试以下方法:
jira = {
"fields":
{
"project":
{
"key": "CIC"
},
"summary": data["story.name"],
"description": data["story.notes"],
"issuetype": { "name": "Sandbox item" }
}
};
//THIS BADASS FUNCTION!!!
jira = JSON.stringify(jira);
$.ajax({
type : "POST",
url : configuration.api_url,
dataType : "JSON",
async : false,
headers: {
"Authorization": "Basic YeahSomethingInAWrap",
"Content-Type": "application/json",
"Accept": "application/json",
"Cache-Control": "no-cache"
},
data : jira,
success : (function(response) {
// Hide loader
l.removeClass("show");
// Alert Success Message
alert("Melding succesvol ontvangen, bedankt!");
// Close dialog
$(".chrome-extension-dialog a.close").trigger("click");
})
});
这篇关于JIRA Rest API错误.无法识别的令牌造成了问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!