Can you share the logs related to this error ?
Feb 17, 2023
10
Level 1
No response is being returned from a CURL POST call with a .csv file in Laravel 9
I have tried to make the CURL call in the following manner:
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL , "http://44.193.201.129:8000/summarize");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: text/csv"
]);
$file = '/opt/lampp/htdocs/multitenant/public/files/iq_data.csv';
curl_setopt($ch,CURLOPT_POSTFIELDS, $file);
$iq_response = curl_exec($ch);
curl_close($ch);
$personascoreobject->iq_test_score = $iq_response;
$personascoreobject->save();
Here the $personascoreobject is the model instance of a table where I am trying to insert the response received from the CURL call in the column iq_test_score. But the response does not return anything . It is returning :
{"error":"500 - Internal server error"}
Whereas when I am separately hit the URL from Postman with the .csv fiIe , I am receiving the response correctly.
Kindly suggest where am I doing the CURL call incorrectly.
Level 63
@ankur_g That means that you have something wrong with curl.
Please or to participate in this conversation.