Posting JSON with curl

Peter Nguyen
Peter Nguyen

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

So for example:

{
  name: 'Peter Nguyen'
}
curl -X POST -H "Content-Type: application/json" -d @../data/names.json http://localhost:8080/person

Alternatively,

curl -X POST -H "Content-Type: application/json" -d '{ "name": "Peter Nguyen" }' http://localhost:8080/person