curl posting with header application/x-www-form-urlencoded
To make a POST
request using curl
and include a header of Content-Type: application/x-www-form-urlencoded
, you can use the following command:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "key1=value1&key2=value2" http://example.com
This will send a POST
request to http://example.com
with a body that is encoded as application/x-www-form-urlencoded
and two form fields: key1
with a value of value1
, and key2
with a value of value2
.
You can also specify the form fields directly in the command line using the -F
option:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -F "key1=value1" -F "key2=value2" http://example.com
This has the same effect as the first example, but allows you to specify the form fields directly on the command line instead of building the key1=value1&key2=value2
string manually.