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-&gt;prepare() #1 /var/www/html/vendor/yiisoft/yii2/web/errorhandler.php(128): yii\web\response-&gt;send() #2 /var/www/html/vendor/yiisoft/yii2/base/errorhandler.php(111): yii\web\errorhandler-&gt;renderexception(object(yii\web\notfoundhttpexception)) #3 [internal function]: yii\base\errorhandler-&gt;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-&gt;runaction(&#039;wewqewqe&#039;, array) #1 /var/www/html/vendor/yiisoft/yii2/web/application.php(102): yii\base\module-&gt;runaction(&#039;categories/wewq...&#039;, array) #2 /var/www/html/vendor/yiisoft/yii2/base/application.php(380): yii\web\application-&gt;handlerequest(object(yii\web\request)) #3 /var/www/html/index.php(16): yii\base\application-&gt;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-&gt;handlerequest(object(yii\web\request)) #1 /var/www/html/index.php(16): yii\base\application-&gt;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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -