Search code examples
laravellaravel-artisan

Laravel 405 error + no api methods in artisan routes:list


I have an error when calling for POST requests through API.

If I calling put method through web.php than everything works fine, however when I request PUT(POST) method via api.php - I have 405 error:

"405 Method Not Allowed"

Moreover if I put command php artisan routes:list in a console I could see solely routes which are placed in web.php file. If I, for example, clean web.php I see an empty routes:list despite the fact that api.php file is full.

Get requests from api.php are processing well.

api.php route file:

<?php

use Dingo\Api\Routing\Router;

$router = app(Router::class);

$router->version('v1', function(Router $router){

  $router->group(['namespace'=>'App\Http\Controllers'], function(Router $router){

      $router->post('test', 'PostController@store');

  });    

});

Solution

  • Such issue could happens if you request your route in Postman through a GET request. Please check it careful if it is not your issue.