Skip to content
Advertisement

“405 Method not allowed” in Laravel 5.6.14

I am just learning laravel resource methods to build a basic API. Below is the code of my api.php file that shows all the API routes.

// List Articles
Route::get('articles', 'ArticleController@index');

// List Single Article
Route::get('article/{id}', 'ArticleController@show');

// Create New Article
Route::post('article', 'ArticleController@store');

// Update Article
Route::put('article', 'ArticleController@store');

// Delete Article
Route::delete('article/{id}', 'ArticleController@destroy');

This works perfectly on get and delete methods. But for Post method, it is throwing error “405 Method not allowed”. I am using Postman to test the API calls.

To be specific, below is the exact error Postman shows

Symfony  Component  HttpKernel  Exception  MethodNotAllowedHttpException

Also attaching screenshot of Postman enter image description here

Advertisement

Answer

Change you store route like this:

Route::post('article/store', 'ArticleController@store');

Because you send post request from Postman to

/article/store

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement