Search code examples
symfonyfosrestbundle

symfony The controller must return a response FOS Rest API


I'm trying to make action like in FOSRestBundleByExample/blob.

My action:

    public function putManagerToMpkAction()
{
    $view = View::create();
    $view->setStatusCode(404)->setData("Error Message");
    return $view;
}

But i have and response:

The controller must return a response (Object(FOS\RestBundle\View\View) given).

I have found i can change view_response_listener to true in my config, but then i have:

Unable to find template "".

Any ideas?

Thanks Kamil


Solution

  • I think you want to do :

    return $this->handleView($view);
    

    Source : http://symfony.com/doc/current/bundles/FOSRestBundle/2-the-view-layer.html