i make a simple api which return some value but if i add this line and pass data like curl_setopt($cURLConnection, CURLOPT_POSTFIELDS , $data);
my api return null here is the complete code
$data = ['a' => "data"];
$url = env('MOTHERSHIP_URL') . '/store/cstore/receipt';
Log::debug("url=" . $url);
$cURLConnection = curl_init();
curl_setopt($cURLConnection, CURLOPT_URL, $url);
curl_setopt($cURLConnection, CURLOPT_POST, true);
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS , $data);
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cURLConnection, CURLOPT_SSL_VERIFYHOST, false);
$apiResponse = curl_exec($cURLConnection);
curl_close($cURLConnection);
$data = json_decode($apiResponse, true);
dd($data);
route
Route::any('/store/cstore/receipt', 'CStoreController@StoreCstoreReceipt')->name('store.cstore.receipt');
controller
public function StoreCstoreReceipt(Request $request){
Log::debug($request->all());
return "Success";
}
problem is if i add curl_setopt($cURLConnection, CURLOPT_POSTFIELDS , $data);
api return null if dont add this line then it works fine what i am doing wrong? i also tried an other method but in this i am getting some html accept of getting response