Curl - techniq/wiki GitHub Wiki

See response headers

curl -i localhost/api/foo

See request and response headers

curl -v localhost/api/foo

POST with string data

Unix:

curl -X POST -d '"foo"' localhost/api/foo

Windows:

curl -X POST -d "\"foo\"" localhost/api/foo

POST with JSON data

Unix:

curl -X POST -H "Content-Type: application/json" -d '{"foo": "bar"}' localhost/api/foo

Windows:

curl -X POST -H "Content-Type: application/json" -d "{\"foo\": \"bar\"}" localhost/api/foo

Send JSON in query string

curl -g 'http://localhost:8080/api/v1/events?where={"distance_kilometers":{">=":7.9,"<":8.1}}'

Handle url data with spaces

 curl -G -v "http://localhost:30001/data" --data-urlencode "msg=hello world"

Return response size

curl -s http://www.whatsmyip.org/http-compression-test/ -w '%{size_download}' -o /dev/null

Authentication / Authorization

JSON Web Token (JWT)

curl localhost -H 'Authorization: Bearer <JWT>'

Pass Windows credentials as part of request

curl --ntlm -u : example.com

Common Access Card (CAC)

See also

⚠️ **GitHub.com Fallback** ⚠️