Have you set .json as the default format in your route?
If you're using FOSRestBundle look at routing_loader
in the FOSRestBundle config
Domanda
I'm trying to generate a url and set the _format variable to json. the .json part is never added to the route. setting to html or xml appends the format correctly.
The route from app/console router:debug
,
api_1_get_page GET ANY ANY /api/page/{id}.{_format}
And my functional test code,
$this->getUrl('api_1_get_page', array('id' => $page->getId(), '_format' => 'json'));
when I dump this I get,
string(18) "/api/pages/1"
Whereas,
$this->getUrl('api_1_get_page', array('id' => $page->getId(), '_format' => 'html'));
returns string(18) "/api/pages/1.html"
I'm guessing there is a setting controlling this, I've tried setting every fos_rest config setting on and off and nothing is making a difference. This is also causing me issues when tests are checking the Location: header expecting .json.
Soluzione
Have you set .json as the default format in your route?
If you're using FOSRestBundle look at routing_loader
in the FOSRestBundle config