JIRA Rest API 错误。无法识别的令牌造成问题

JIRA Rest API error. Unrecognized token creating a issue

未能通过 AJAX 和 REST API 添加问题。我可以让它与 Postmen 一起工作,不幸的是,无法通过 Ajax 请求获得它。

我创建的JSON没问题,post请求也可以。问题类型是我自己创建的,使用 Bug 会出现同样的问题。查看创建的 JSON 对象、我的错误和我的代码: JSON 对象(这是 console.log 的片段):

错误

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");

    })
}); 

您需要 JSON.stringify 您的 jira 变量才能发送。