prudhvi259
prudhvi259

Reputation: 547

Delete request using guzzle in laravel not working

I am developing an API using resource controller in laravel. To call this api from my client i am using guzzle(my client is also laravel). For POST and GET requests it worked fine but for delete request it is showing below error.
enter image description here

My delete request is

$client = new Client();
$res = $client->delete('http://localhost:8017/opendemo_old/public/TestAPI/123456');

Below are my post and get request which are working fine.

$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/>

I am not getting what's the problem with delete request. I am using guzzle 6 and laravel 5.2(client & server).

Upvotes: 0

Views: 1589

Answers (1)

ahmeti
ahmeti

Reputation: 504

Another way to DELETE request for Laravel.

$client = new Client();
$res = $client->post('http://localhost:8017/opendemo_old/public/TestAPI/123456', [
    'form_params' => [
        '_method' => 'DELETE'
    ]
]);

Upvotes: 1

Related Questions