How to get Rails to respond with json based on headers
<p>I'm building an API with Rails 4 and in my controller I'm using <code>respond_to</code> to differentiate between <code>html</code> and <code>json</code> request which all works fine. While testing my API in Postman, I've added the following header: <code>Content-Type: application/json</code> but in my request I still need to add <code>.json</code> at the end of it like so: <code>https://myapi.com/api/users.json</code> otherwise Rails will respond with <code>html</code> even though the aforementioned header is present. </p>

<p>My question is this: is there a way that Rails can recognise the <code>Content-Type: application/json</code> header and respond with <code>json</code> without me using the <code>.json</code> part in the url like so: <code>https://mypai.com/api/users</code>?</p>