November 30, 2017

curl Usage

HTTP request method:
  • -X POST
  • -X PUT
HTTP request Content-Type header
  • -H "Content-Type: application/x-www-form-urlencoded"
  • -H "Content-Type: application/json"
HTTP request body/data
  • form urlencoded: -d "param1=value1&param2=value2"
  • json: -d '{"key1":"value1", "key2":"value2"}'
Examples

curl -X GET http://www.google.se
curl -d "param1=value1&param2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:3000/data
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data

https://gist.github.com/subfuzion/08c5d85437d5d4f00e58

No comments: