Do you own the code for the API?
Feb 3, 2021
4
Level 1
Sending massive data to an API
Hello community.
I am trying to import a CSV data to an API and i getting this error: cURL error 52: Empty reply from server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://IPAddress:3000/cl/back/subido/create
I tried sending data like this:
$response = Http::post('IPAddress:3000/cl/back/subido/create',[
'libre' => 'Esto es una prueba',
'names' => 'Peter',
'last_name' => 'Gutierrez'
]);
And it works
But when i extract data from a CSV doesnt
this is how i am doing
My Controller:
public function store(Request $request)
{
/* Cache::flush(); */
$file = $request->file('file');
Excel::import(new CandidatosImport, $file);
return back()->with('info','Successfull');
}
My Import File:
public function model(array $row)
{
$response = Http::post('IPAddress:3000/cl/back/subido/create',[
'libre' => 'Esto es una prueba',
'nombres' => $row[1],
'apellidos' => $row[2],
'email' => $row[11],
'clave' => '123',
'dia' => 5,
'mes' => 2,
'ano' => 2005,
'rut' => 22222222,
'dig' => '1',
'genero' => $row[6],
'cargo' => 'ALCA',
'partido' => $row[8],
'par_nom' => 'INDEPENDIENTE',
'region' => $row[4],
'provincia' => $row[3],
'comuna' => '13202',
'lista' => 'F'
]);
}
public function getCsvSettings(): array
{
return [
'input_encoding' => 'ISO-8859-1',
'delimiter' => ";"
];
}
I will appreciate if someone help me, please.
Please or to participate in this conversation.