For some reason i am getting :
{
"name": "Not Found",
"message": "Object not found: search",
"code": 0,
"status": 404,
"type": "yii\web\NotFoundHttpException"
}
when I try to access a custom action (http://localhost/project/api/web/v1/userfunctions/search) in my yii2 rest api app. This is what I have in the main.php configuration file
[
'class' => 'yii\rest\UrlRule',
'controller' => 'v1/userfunction',
'extraPatterns' => ['GET search' => 'search'],
'tokens' => [
'{id}' => '<id:\\w+>'
]
]
And the UserFunctionController
class has a actionSearch
method.
Am I missing something here?
When I add a blank action method :
public function actions()
{
$actions = parent::actions();
return $actions;
}
method the 404 goes away but i get a blank response (status code 200) [This is irrespective of whether the actionSearch is defined or not] Where does the control go in this case?
Here is the actionSearch()
code
public function actionSearch()
{
$output = UserStatus::findAll();
return $output;
}