CURL not working when POSTING json to my Web Service CURL not working when POSTING json to my Web Service curl curl

CURL not working when POSTING json to my Web Service


Did you try erichelgeson's suggestion?

The correct curl method is

curl -H "Content-Type:application/json" -X POST -d '{"cityName":"NewYork", "countryCode":"IT", "postalCode": "00166"}' http://localhost:8080/ComuneUtenti/api/city

Notice the single quotes around the json payload.

To see what's really going on you can use the echo command.

$ echo {"hello":"world"}{hello:world}$ echo '{"hello":"world"}'{"hello":"world"}

The shell is eating the quotes around your fields.


What version of grails 2.3 are you using?Grails 2.3.8 had a bug where you could not post to rest services.

I believe this was the checked in here.

https://github.com/grails/grails-core/commit/c050212fa0992f5b2d62c8e63795e4278fb2c3f4