cURL POST Request

Posted Under: cURL, PHP, Shell, Tutorials on Feb 18, 2022
cURL POST Request
There are many HTTP methods available to clients to access data and resources from server. Most used HTTP methods are GET and POST. GET request are simple and request is part for URL. It supports up to 4 KB of data sent as part of URL to the server. In POST huge amount of data can be sent. The data is sent as part of the HTTP body rather than part of the HTTP header.

cURL POST Request With Parameter Example

//POST data array
$cURLHandle= curl_init();
curl_setopt($cURLHandle, CURLOPT_URL,"https://www.tutorialjinni.com/endpoint.py");
curl_setopt($cURLHandle, CURLOPT_RETURNTRANSFER,true);
curl_setopt($cURLHandle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($cURLHandle,CURLOPT_POST, true); //Telling cURL we to send POST Request
curl_setopt($cURLHandle, CURLOPT_POSTFIELDS,$POST_PARAMS); // POST data array
$html = curl_exec($cURLHandle);
echo $html;

cURL POST Data from Terminal

curl --data "POST_PARAM_1=VALUE_4&POST_PARAM_2=VALUE_2" "https://www.tutorialjinni.com/endpoint.py"