Closed abayomiabayomi closed 3 years ago
How about 2.0.39?
How about 2.0.39?
I have downgraded to 2.0.39 and the issue remains. Rest api still does not work.
Your action is mybook
- how do you have this configured that you expect api/books
to work?
Your action is
mybook
- how do you have this configured that you expectapi/books
to work?
Yes action is mybook
and url is like this http://localhost/gig_books/backend/web/index.php/api/mybook. I made a typo error when posting.
Error remains. I have downgraded as far back as 2.0.15 and its same issue but when i go back to the original version, api works okay.
I'm not sure if can find the cause of it without your help. Could you debug the request to find the place where you are getting NotFoundHttpException? Switching on the debug logs with trace level and showing the output would be helpful as well.
I'm not sure if can find the cause of it without your help. Could you debug the request to find the place where you are getting NotFoundHttpException? Switching on the debug logs with trace level and showing the output would be helpful as well.
Thank you bizley. These are the logs:
2020-12-30 05:25:18 [::1][4][e3c1ss96o0ant3el1b3kjso7g6][error][yii\web\HttpException:404] yii\base\InvalidRouteException: Unable to resolve the request "api/mybook". in C:\wamp64\www\gig_books\vendor\yiisoft\yii2\base\Module.php:537
Stack trace:
#0 C:\wamp64\www\gig_books\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('api/mybook', Array)
#1 C:\wamp64\www\gig_books\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 C:\wamp64\www\gig_books\backend\web\index.php(21): yii\base\Application->run()
#3 {main}
Next yii\web\NotFoundHttpException: Page not found. in C:\wamp64\www\gig_books\vendor\yiisoft\yii2\web\Application.php:115
Stack trace:
#0 C:\wamp64\www\gig_books\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\wamp64\www\gig_books\backend\web\index.php(21): yii\base\Application->run()
#2 {main}
2020-12-30 05:25:18 [::1][4][e3c1ss96o0ant3el1b3kjso7g6][info][application] $_GET = []
Setting log level to trace
would be better. I'll try to dry-run the 2.0.1 version and see what are the differences in handling this.
Ok, I think I found it. It's all because of this line in Module::createControllerByID().
Your controller is in the file named ApiController.php
but your controller is named APIController
(notice uppercase API).
The check mentioned above is there to prevent such mistakes and it was introduced in 2.0.4.
Ok, I think I found it. It's all because of this line in Module::createControllerByID().
Your controller is in the file named
ApiController.php
but your controller is namedAPIController
(notice uppercase API).The check mentioned above is there to prevent such mistakes and it was introduced in 2.0.4.
Whao!!! Thats it. It worked. Thank you @bizley
I have just upgraded my Yii 2.0 app to 2.0.40. The app has served me well without issues. However, after update my rest api no longer works. It gives a consistent "Not Found (#404). Page not found" error. Whenever i go back to my backup previous Yii version, the rest api works well there but it just will not work on 2.0.40. This issue occurs both on my local server and web server
What steps will reproduce the problem?
Upgrade from yii2.0.1 to yii2.0.40 and PHP from PHP 7.1 to PHP 7.3 After upgrade, i call the api here http://localhost/gig_books/backend/web/index.php/api/mybook
What is the expected result?
It displays the requested content in json format
What do you get instead?
Not Found (#404) Page not found. The above error occurred while the Web server was processing your request. Please contact us if you think this is a server error. Thank you.
Additional info
gig_books/common/config/main-local.php
gig_books/backend/controllers/ApiController.php