传递给GuzzleHttp\Client::send()的参数1必须实现接口



hi我是laravel的新手,我正在尝试使用laravel 8的api我的POST有问题,我不理解

public function storeEntreprise(Request $request){
$request->validate([
'name' => 'required',
'email' => 'required',
'phone_number'=>'required',
'address' => 'required',
'password' => 'required',
'password_confirmation' => 'required'
]);
$client = new Client();
$post = $request->all();
$url = "http://flexy-job.adsyst-solutions.com/api/entreprises-store";
$create = $client->request('POST', $url, [
'headers' => [
'Content-Type' => 'text/html; charset=UTF8',
],
'form-data' => [
'name'           => $post['name'],
'email'        => $post['email'],
'phone_number'          => $post['phone_number'],
'address'          => $post['address'],
'logo'        => $post['logo'],
'password'       => $post['password'],
'password_confirmation'      => $post['password_confirmation']
]
]);
//dd($create->getBody());
echo $create->getStatusCode();
//echo $create->getHeader('Content-Type');
echo $create->getBody();
$response = $client->send($create);
return redirect()->back();
}

你能帮我吗

您调用(意外?($response = $client->send($create);,其中$create是您发出的API请求的响应($create = $client->request('POST', $url, ...(。

所以PHP报告您不能在需要RequestInterface的地方通过ResponseInterface

此外,您还可以echo的响应体,并同时返回重定向响应。所以浏览器不会显示API响应(因为实例反向重定向(。

最新更新