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
Advertisement
Answer
Change you store route like this:
Route::post('article/store', 'ArticleController@store');
Because you send post request from Postman to
/article/store