如何使用REST API在Jira Service Desk中创建问题

问题描述

我对API领域完全陌生,我尝试使用Jira API在Jira Service Desk中创建一个Issue / Ticket,但即使多次尝试也无法实现。 如果有人掌握了使用bash shell / powershell / python在Jira Service Desk中创建Issue / ticket的命令/代码,将大有帮助。

C:\Windows\system32>curl -D- -u user:password -X POST --data { "serviceDeskId": "10205","requestTypeId": "10000","requestFieldValues": { "summary": "Request JSD help via REST","description": "Desc Request JSD help via REST" }  -H "Content-Type: application/json" https://jjiraservicedeskurl/rest/api/2/issue/
curl: (6) Could not resolve host: serviceDeskId
curl: (6) Could not resolve host: 10205,curl: (6) Could not resolve host: requestTypeId
curl: (6) Could not resolve host: 10000,curl: (6) Could not resolve host: requestFieldValues
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: summary
curl: (6) Could not resolve host: Request JSD help via REST,curl: (6) Could not resolve host: description
curl: (6) Could not resolve host: Desc Request JSD help via REST
curl: (3) [globbing] unmatched close brace/bracket in column 1
HTTP/1.1 400
X-AREQUESTID: 1037x7716x1
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
x-frame-options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-ASEN: SEN-L15877282
Set-Cookie: JSESSIONID=9B5B3DA5D899E1897DC909CC57D94F78; Path=/; Secure; HttpOnly
X-Seraph-LoginReason: OK
Set-Cookie: atlassian.xsrf.token=BK2L-I3HA-D24Q-1X7S_ba3e1671ccd8a2bafa38871b994d5387159243b6_lin; Path=/; Secure
X-ASESSIONID: 16z1cmb
X-AUSERNAME: mill_adv_user_test
Cache-Control: no-cache,no-store,no-transform
Content-Type: application/json;charset=UTF-8
transfer-encoding: chunked
Date: Mon,07 Sep 2020 17:17:14 GMT
Connection: close

{"errorMessages":["Unexpected end-of-input: expected close marker for OBJECT (from [Source: org.apache.catalina.connector.CoyoteInputStream@17a62b93; line: 1,column: 0])\n at [Source: org.apache.catalina.connector.CoyoteInputStream@17a62b93; line: 1,column: 3]"]}
C:\Windows\system32>

解决方法

已解决

在文件数据中输入数据

{
    "fields": {
       "project":
       { 
           "key": "TEST"
       },"summary": "REST EXAMPLE","description": "Creating an issue via REST API","issuetype": {
           "name": "Incident"
       }
   }
}

卷曲命令:

curl -D- -u user:password -X POST --data-binary "@data"  -H "Content-Type: application/json" https://jiraservicedeskurl/rest/api/2/issue/