使用JIRA REST API创建问题时出错

时间:2016-05-03 10:07:27

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

我正在尝试使用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]"]}

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

我明白了:

命令

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

FILENAME.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"
       }
   }
}

这有效:)