Cheatsheet: curl

Basic operations

Send a GET request to a URL

curl ""

Send a POST request with data

curl --data "firstName=John" ""

Send a POST request with JSON data

curl -H "Content-Type: application/json" -X POST -d '{"firstName":"John"}'  ""

Send a PUT request with data:

curl -X PUT --data "firstName=John" "

Send a DELETE request:

curl -X DELETE ""

Send a request with a custom header

curl -H "appKey: asdf123123" ""

Send a request with Basic Authentication

curl -u username:password ""

Send a request and save the response to a file

curl "" -o filename.txt

Send a request and follow redirects

curl -L

Send a request and display the response headers

curl -i