Pregunta

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?

¿Fue útil?

Solución

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.

Otros consejos

Your --data should look something like:

"{ \"fields\": {\"project\": { \"key\"=\"ZZZ-180\" }, \"summary\": \"REST TESTING\" , \"description\": \"Creation of a testing issue\" , \"issuretype\" { \"name\": \"Bug\"}}}"
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top