[英]How to attach an image when creating an JIRA issue by using JIRA REST APIs
[英]JIRA Rest API error. Unrecognized token creating a issue
通過AJAX和REST API添加問題沒有好運。 我可以讓它與Postmen合作,不幸的是,無法通過Ajax請求得到它。
我創建的JSON很好,也是post請求。 issuetype是我自己創建的,使用Bug會產生同樣的問題。 查看創建的JSON對象,我的錯誤和我的代碼:JSON對象(這是來自console.log的代碼片段):
錯誤
0:“無法識別的標記'fils5poet5':在[來源:org.apache.catalina.connector.CoyoteInputStream@7b958ed2; line:1,column:21]中期待'null','true','false'或NaN↵”
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
}})
在發送之前,您需要JSON.stringify
您的jira變量。
你可以嘗試這樣的事情:
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");
})
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.