Curl with POST data


curl --verbose -X POST --data "field1=value1&field2=value2" http://www.example.com/form.html

For APIs that expect JSON bodies:

curl \
  --data '{"field1":"value1","field2":"value2"}' \
  --header "Content-Type: application/json" \
  --verbose \
  -X POST \
  https://www.example.com/api/endpoint

Use --data @filename to send from a file.

Use --data @- to send from stdin.

Date: 2017-05-23

Tags:  curl

Share: