i use guzzle to send datas to my api and i'm getting an exception. here is the code in my controller
public function Connecter(Request $request){
$parametre =$request->all();
$client = new Client();
$r = $client->post('http://myapiurl.com/login',['body'=>$parametre]);
$user = json_decode($r->getBody(),true);
if ($user) {
$sis = $user['user'];
Session::put('id', $sis['id']);
Session::put('nom', $sis['name']);
Session::put('role', $sis['id_roles']);
Session::put('email', $sis['email']);
return redirect()->route('home');
}else{
return redirect()->back();
}
}
and when i see the log, i found this
[2017-09-11 16:31:25] production.ERROR: GuzzleHttp\Exception\ClientException: Client error response [url] http://myapiurl.com/login [status code] 403 [reason phrase] Forbidden in /home/vol2_6/myserver.com/username/htdocs/laravel/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:89 Stack trace:
when i do
dd($r = $client->post('http://myapiurl.com/login',['body'=>$parametre]);
);
i get 403 Forbidden
csrf-token
field. – aleksejjj