【问题标题】:JIRA Rest API error. Unrecognized token creating a issueJIRA 休息 API 错误。无法识别的令牌创建问题
【发布时间】:2015-03-05 03:46:36
【问题描述】:

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

我创建的 JSON 很好,post 请求也很好。问题类型是我自己创建的,使用 Bug 给出了同样的问题。查看创建的 JSON 对象、我的错误和我的代码: JSON 对象(这是来自 console.log 的 sn-p):

错误

0: "无法识别的标记 'fils5poet5': 期待 'null', 'true', 'false' 或 NaN↵ 在 [来源: org.apache.catalina.connector.CoyoteInputStream@7b958ed2;线:1, 列: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
}})

【问题讨论】:

    标签: ajax json rest jira jira-rest-api


    【解决方案1】:

    您需要在发送之前JSON.stringify 您的 jira 变量。

    【讨论】:

      【解决方案2】:

      你可以试试这样的:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多