Kamil P
Kamil P

Reputation: 784

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

Upvotes: 1

Views: 1950

Answers (1)

tchap
tchap

Reputation: 3432

I think you want to do :

return $this->handleView($view);

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

Upvotes: 3

Related Questions