icon sc-linkedin logo of codepen-icon logo of github-icon youtube play button

notes by Adam Sullovey

web & mobile application developer
practicing in Toronto, ON

Command line cURL request with JSON

This is useful for testing out REST services that use JSON, like ones made with Restify and MongoDB. This command runs in Linux, OS X, or even Windows if you have cURL installed and included in your PATH variable.

curl -is http://localhost:3000/users/501c34d0261bb43c15000001 -X PUT -d '{"thingers":["stuff","pie"]}' -H "Content-Type: application/json"

The important flags are -X for setting which method to use, and -H so that the server knows to check the request body for the data instead of the URL or POST data in the request headers.

comments powered by Disqus