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