curl -d '{"key": "value"}' -X POST -H 'Content-Type: application/json' http://localhost:8080/post
To send the content of a file:
-d @filename.json
To accept a JSON response (a GET request i.e.):
-H 'Accept: application/json'
To post an HTML form:
-H "Content-Type: application/x-www-form-urlencoded"
-d "param1=value1¶m2=value2"
Ignore SSL errors:
-k
To authenticate basic HTTP:
-u "login:password"
To download a file:
-o filename.txt
Windows Notes:
Download curl binary from: https://curl.se/windows/dl-8.12.1_4/curl-8.12.1_4-win64-mingw.zip
Rename (to _curl.exe
), because PowerShell has a curl
command, and escape JSON surronding with '..'
and using \"...\"
in fields and values, example:
_curl -H 'Content-Type: application/json' -d '{\"id\": \"1\", \"firstName\": \"Andres\", \"lastName\": \"Guerrero\"}' -X POST http://localhost:8080/employees
Tags linux command