How to perform a POST request using curl?

  1. Accepted Answer - Simple POST request

Accepted Answer - Simple POST request

To make a simple POST request, use curl -X POST e.g.

curl -X POST

Sending additional fields

To send additional fields with the POST request, use the -d flag with data. Note that this will add the Content-Type: application/x-www-form-urlencoded header to the request.

curl -d "user=admin&pass=secret" -X POST

To change the header in order to send a specific data type, such as JSON, use the -H flag.

curl -d '{user}' -H 'Content-Type: application/json'

Speak Your Mind