I needs to implement below curl command in PHP. curl -X POST "http://XXXXXXXXX/api/service" -F "scenario=http://XXXXXXXXX/api/service/scenarios/3728940075"
For this i have written below code but its throwing 400 bad request. Please help me
$postdata = array("scenario" => "http://XXXXXXXXX/api/service/scenarios/3728940075" );
echo " --- cURL postdata #:" . $postdata;
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, false);
curl_setopt($curl,CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_URL, "http://XXXXXXXXX/api/service");
//curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
//curl_setopt($curl,CURLOPT_POST, count($postdata));
curl_setopt($curl,CURLOPT_POSTFIELDS, $postdata);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($curl, CURLOPT_FAILONERROR, true);
$response = curl_exec($curl);
echo " --- cURL response #:" . $response;
$err = curl_error($curl);
echo " --- cURL Error #:" . $err;
curl_close($curl);
if ($err) {
echo "<h2> Error found in setting up trigger. Please contact the Start Administrator</h2>";
echo "cURL Error #:" . $err;
} else {
echo " ---- setupTrigger -------".$response;
return $response;
}
Please help me to resolve this issue