Reputation: 175
I need to automate the issues insertion in Jira, so I need to use a REST API, I run the curl from the command line, here is my command
C:\WINDOWS\system32>curl.exe -D- -u fred:fred -X POST --data { "fields": {"project": { "key"="ZZZ-180" }, "summary": "REST TESTING" , "description": "Creation of a testing issue" , "issuretype" { "name": "Bug"}}} -H "Content-Type: application/json" http://ABCD.com:XXXX/rest/api/2/issue/
and here is what I receive:
curl: (6) Could not resolve host: fields
curl: (3) [globbing] unmatched brace at pos 10
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: key=
curl: (6) Could not resolve host: ZZZ-180
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (6) Could not resolve host: summary
curl: (6) Could not resolve host: REST TESTING
curl: (6) Could not resolve host: ,
curl: (6) Could not resolve host: description
curl: (6) Could not resolve host: Creating of a testing issue
curl: (6) Could not resolve host: ,
curl: (6) Could not resolve host: issuretype
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: name
curl: (3) [globbing] unmatched close brace/bracket at pos 4
Can anyone help me let the cURL define the JSON code written in data?
Upvotes: 2
Views: 6591
Reputation: 31
Your --data should look something like:
"{ \"fields\": {\"project\": { \"key\"=\"ZZZ-180\" }, \"summary\": \"REST TESTING\" , \"description\": \"Creation of a testing issue\" , \"issuretype\" { \"name\": \"Bug\"}}}"
Upvotes: 0
Reputation: 33106
You would have to quote the string, but simplest way is putting JSON data in a file and asking cURL to read from it:
C:\WINDOWS\system32>curl.exe -D- -u fred:fred -X POST --data @data_to_send.json -H "Content-Type: application/json" http://ABCD.com:XXXX/rest/api/2/issue/
Note the @
before file name.
Upvotes: 3