我正在使用laravel中的资源控制器开发API。要从我的客户端调用此api,我使用guzzle(我的客户端也是laravel)。对于POST和GET请求,它工作正常,但对于删除请求,它显示如下错误
我的删除请求是
$client = new Client();
$res = $client->delete('http://localhost:8017/opendemo_old/public/TestAPI/123456');
以下是我的帖子和获取请求,工作正常。
$client = new Client();
$res = $client->request('POST', 'http://localhost:8017/opendemo_old/public/TestAPI', [
'form_params' => [
'field_name' => 'abcddd',
'other_field' => '12344',
'nested_field' => [
'nested' => 'hello'
]
]
]);
$client = new Client();
$res = $client->request('GET', 'http://localhost:8017/opendemo_old/public/TestAPI/123'); <br/>
我没有得到删除请求的问题。我正在使用guzzle 6和laravel 5.2(客户端和服务器)。
答案 0 :(得分:0)
删除请求 Laravel 的另一种方法。
$client = new Client();
$res = $client->post('http://localhost:8017/opendemo_old/public/TestAPI/123456', [
'form_params' => [
'_method' => 'DELETE'
]
]);