Curl post request in command line with example
curl is a command line tool which is used to transfer data. It supports almost all major protocols such as ftp, http, https etc. We can use this command to make POST request to a webpage, In fact we have more than one way to make a post request using curl command.
These are the options available in curl command to make post request
curl --data "field1=value1&field2=value2" http://sample.com/test.php
curl --data '' http://sample.com/test.php
curl -X POST http://sample.com/test.php
curl --request POST http://sample.com/test.php
We can also upload files using curl command, check this example,
curl --form "fileupload=@file.txt" http://sample.com/test.php
curl --form "fileupload=@file.txt;filename=filename.txt" http://sample.com/test.php
These are the options available in curl command to make post request
curl --data "field1=value1&field2=value2" http://sample.com/test.php
curl --data '' http://sample.com/test.php
curl -X POST http://sample.com/test.php
curl --request POST http://sample.com/test.php
We can also upload files using curl command, check this example,
curl --form "fileupload=@file.txt" http://sample.com/test.php
curl --form "fileupload=@file.txt;filename=filename.txt" http://sample.com/test.php
Comments (0)