I resolved the same problem :
this is my config :
fos_rest:
body_listener: true
view:
view_response_listener: force
format_listener:
rules:
- { path: '^/', fallback_format: json }
Hope it's helpful
Domanda
config.yml:
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'
fos_rest:
routing_loader:
default_format: json
view:
view_response_listener: force
force_redirects:
html: true
format_listener:
rules:
- { path: '^/api', fallback_format: json }
- { path: '^/', fallback_format: html }
param_fetcher_listener: force
body_listener: true
exception:
codes:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException': 404
'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
But html is returned:
...<h2><span>2/2</span> <abbr title="Symfony\Component\HttpKernel\Exception\NotFoundHttpException">NotFoundHttpException</abbr>: No route found for "GET /api/user/jFvms0rp%20"</h2>...
How to turn it to json?
Soluzione
I resolved the same problem :
this is my config :
fos_rest:
body_listener: true
view:
view_response_listener: force
format_listener:
rules:
- { path: '^/', fallback_format: json }
Hope it's helpful