php - Yii2 REST API not working properly -
i creating api user yii2 user api user id. if pass user id working if pass string below error.
<pre>an error occurred while handling error: yii\base\invalidparamexception: response content must not array. in /var/www/html/vendor/yiisoft/yii2/web/response.php:1020 stack trace: #0 /var/www/html/vendor/yiisoft/yii2/web/response.php(313): yii\web\response->prepare() #1 /var/www/html/vendor/yiisoft/yii2/web/errorhandler.php(128): yii\web\response->send() #2 /var/www/html/vendor/yiisoft/yii2/base/errorhandler.php(111): yii\web\errorhandler->renderexception(object(yii\web\notfoundhttpexception)) #3 [internal function]: yii\base\errorhandler->handleexception(object(yii\web\notfoundhttpexception)) #4 {main} previous exception: yii\base\invalidrouteexception: unable resolve request: categories/wewqewqe in /var/www/html/vendor/yiisoft/yii2/base/controller.php:127 stack trace: #0 /var/www/html/vendor/yiisoft/yii2/base/module.php(523): yii\base\controller->runaction('wewqewqe', array) #1 /var/www/html/vendor/yiisoft/yii2/web/application.php(102): yii\base\module->runaction('categories/wewq...', array) #2 /var/www/html/vendor/yiisoft/yii2/base/application.php(380): yii\web\application->handlerequest(object(yii\web\request)) #3 /var/www/html/index.php(16): yii\base\application->run() #4 {main} next yii\web\notfoundhttpexception: page not found. in /var/www/html/vendor/yiisoft/yii2/web/application.php:114 stack trace: #0 /var/www/html/vendor/yiisoft/yii2/base/application.php(380): yii\web\application->handlerequest(object(yii\web\request)) #1 /var/www/html/index.php(16): yii\base\application->run() #2 {main}</pre>
i using swagger
executing apis , endpoint of api is
users/{id}
work fine when enter
/users/1
get error when
/users/asdf
web.php
'users/<id:\d+>' => 'users/',
i have faced same issue , has been solved change in routing in web.php in config folder.
change url users/<id>
instead of users/<id:\d+>.
Comments
Post a Comment