I don't get how to customize error pages, in a JSON format for a REST API, written with Symfony. I made this small demo :
As you can see, the project is set up with the Twig Bundle and I have customized the 404 pages in JSON format..
I Have tested the API with the dev server.
- In dev mode, I get the JSON message with the dedicated URL (http://localhost:8000/_error/404.json)
-
In prod mode, When I call the API with a wrong URI :
curl -H "Content-Type:application/json" -H "Accept: application/json" -i http://localhost:8000/api/v1/vols
The client received HTML 404 page and not JSON format (the header send with the curl command is supposed to set symfony to a response in JSON format).