【问题标题】:Getting error while creating issue with JIRA REST API使用 JIRA REST API 创建问题时出错
【发布时间】:2016-05-03 10:07:26
【问题描述】:

我正在尝试使用 JIRA API 创建问题,我正在尝试使用 curl 发布此问题:

curl -D- -u username:password -X POST --data filename.txt -H "Content-Type: application/json" https://<JIRA_BASEURL>/rest/api/2/issue/

在 filename.txt 中使用此数据:

{
"fields": {
   "project":
   { 
      "key": "PROJECT-key"
   },
   "summary": "REST EXAMPLE",
   "description": "Creating an issue via REST API",
   "issuetype": {
      "name": "Bug"
   }
  }
}

我收到一个我无法理解的错误

HTTP/1.1 400 Bad Request
Server: nginx
Date: Tue, 03 May 2016 09:57:03 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-AREQUESTID: 174x4470x1
X-ASEN: SEN-34722393
X-Seraph-LoginReason: OUT
X-Seraph-LoginReason: OK
X-ASESSIONID: jhs5ewrt4bh
X-AUSERNAME: username
X-ATENANT-ID: jira.atlassian.net
Cache-Control: no-cache, no-store, no-transform
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=41A2A4ABC78BDABCA7B13FB45E3; Path=/; Secure; HttpOnly
Set-Cookie: studio.crowd.tokenkey=""; Domain=.jira.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Set-Cookie: studio.crowd.tokenkey=65IUtfdCjefQ8UlVlh00; Domain=.jira.atlassian.net; Path=/; Secure; HttpOnly
Set-Cookie: atlassian.xsrf.token=BLSG-CYWX-OPRE-Y0WF|e3453a213679767e6370dt637e97f58|lin; Path=/; Secure

{"errorMessages":["Unrecognized token 'fieaett': was expecting 'null', 'true', 'false' or NaN\n at [Source: org.apache.catalina.connector.CoyoteInputStream@fb9e08; line: 1, column: 26]"]}

谁能帮我解决这个问题?

【问题讨论】:

    标签: curl jira-rest-api http-status-code-400


    【解决方案1】:

    我想通了:

    命令

    curl -D- -u username:password -X POST --data-binary "@filename.txt" -H "Content-Type: application/json" https://<JIRA_BASEURL>/rest/api/2/issue/
    

    文件名.txt:

    {
        "fields": {
           "project":
           { 
              "key": "TEST"
           },
           "summary": "REST ye merry.",
           "description": "Creating of an issue using project keys and issue type names using the REST API",
           "issuetype": {
              "name": "Bug"
           }
       }
    }
    

    这行得通:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-21
      • 2012-10-20
      • 1970-01-01
      • 2015-11-25
      • 1970-01-01
      相关资源
      最近更新 更多