I am using dingo/api for a project and all of my routes work other than 1.
routes.php
$api = app('api.router');
$api->version('v1',['prefix' => 'api'], function ($api) {
$api->post('users', "App\Http\Controllers\Auth\UsersController@store");
...
});
store method :
/**
*
* @param \App\Http\Requests\Auth\StoreUserRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreUserRequest $request)
{
if( ! $this->isAdminRequest() )
{
return $this->dispatch(new RegisterUserCommand($request));
}
}
This route throws 405 Method Not Allowed Exception
.
php artisan api:routes
shows that it is registered, both locally and on server.
I am using POSTMAN to test my api and have all required fields.
In response I do get Allow : POST.
NOTE :
- There are other post routes that work perfectly.
- There are other UsersController routes that work perfectly
- I have tried removing all other routes and with just this, it still does not work.
Any help is appreciated. Thanks.
UPDATE :
Okay, it was a really silly mistake on my part. I was hitting 'domain/api/users/'. Removing the trailing '/' worked. But the thing is, locally '/' works and not on server. So keeping this question on for some explanantion maybe.