0

I have the same question as this .And the second answer there solved my problem.The solution is

sensio_framework_extra:
    view:   {   annotations: false }
    router: {   annotations: true }

fos_rest:
    param_fetcher_listener: true
    body_listener: true
    format_listener: true
    view:
        view_response_listener: 'force'
        formats:
            xml: true
            json : true
        templating_formats:
            html: true
        force_redirects:
            html: true
        failed_validation: HTTP_BAD_REQUEST
        default_engine: twig
    routing_loader:
        default_format: json

But i dint understand how this solved the problem and why dint this configuration solved my problem.

fos_rest:
    routing_loader:
        default_format: json
    view:
        view_response_listener: true    

Can anyone explain me the configuration.

Community
  • 1
  • 1
user3425344
  • 3,357
  • 4
  • 20
  • 31

1 Answers1

0

As explained in the documentation, the option view_response_listener permits to return a View instead of a Response. Then, the service responsible for converting the view to a response (among other things) takes care of your view and builds the response.

In the original issue, the missing configuration didn't permit the FOSRestBundle to take care of the returned data and to process the view, which is the reason of the error.

See more here.

MeuhMeuh
  • 826
  • 6
  • 26