How to get json format data without the .json or ?format=json postfix in the url?

I have tried to set the "Accept: application/json" header, but it
didn't work. all i could get was the "406 Not Acceptable" status code.

Below was the command what i used to make the request:

curl -i -X POST -H "Content-Type: application/json" -H "Accept:
application/json" -d "{ title: \"foo\", body: \"bar\" }"
http://127.0.0.1:3000/posts

and here the result:

HTTP/1.1 406 Not Acceptable
Connection: close
Set-Cookie:
_xml_test_session=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo
%0ASGFzaHsGOgtub3RpY2UiI1Bvc3Qgd2FzIHN1Y2Nlc3NmdWxseSBjcmVhdGVk
%0ALgY6CkB1c2VkewY7BkY%3D--41fbe342052f993cdaebf3ad9c431fb7537e8d4e;
path=/
Status: 406 Not Acceptable
X-Runtime: 0.02510
Cache-Control: no-cache
Server: Mongrel 1.1.5
Content-Type: text/html; charset=utf-8
Content-Length: 1

if i use http://127.0.0.1:3000/posts.json or http://127.0.0.1:3000/posts?format=json,
i would get the proper result.