0
我有两个应用程序,一个是API,另一个是连接到该API并通过api添加,删除,编辑项目。现在我可以选择和插入,但我坚持更新。Guzzle - 如何在Laravel中发送PUT请求
这是我正在尝试这样做:
public function update($id)
{
$client = new GuzzleHttp\Client();
$res = $client->put('http://api.dev/api/v1/locations', [
'auth' => ['David', '888177'],
'body' => ['id' => Input::get('id'),
'name' => Input::get('name'),
'address' => Input::get('address'),
'postal_code' => Input::get('postal_code'),
'city' => Input::get('city'),
'indication' => Input::get('indication'),
'comment' => Input::get('comment')]
]);
return Redirect::route('locations.show', Input::get('id'));
}
但我得到这个eror:
GuzzleHttp \ Exception \ ClientException
Client error response [url] http://api.dev/api/v1/locations [status code] 405 [reason phrase] explicit_header_response_code
如果我试试这个,卷曲它工作正常,所以我知道API方面工作正常:
curl -i -X PUT --user David:888177 -d 'name=testname' http://api.dev/api/v1/locations/137