Api controller not found exception

Hi…All
I am getting error when i start work on Api’s. I am following Cakephp Documentation as they mention in Router Page Restful Api Router:-


So I am following same steps in my application :-


But As You can see My Api controller in Controller/Api/AccountController.php and I am calling this from url /api/v1/accounts/login.php but it throw Error Api controller could not found and this issue only exist in 5.1.1 cakephp version not in cakephp 5.1.0.
I am also using Authorization/Authentication plugin and Policy
You can see on the browser throw Controller Class Api not found…

And in Api folder there is two files ApiController.php And AccountsController.php

yeah! i know why it throw error,actually this is middleware level Exception… I bet you missed RequestMiddleware in Application.php

->add(new RequestAuthorizationMiddleware())
please copy and past in middleware, I hope it will fix you problem.

1 Like

yeah! its really fixed my issue. thanks @shaan007