Forum: Ruby on Rails 406 Not Acceptable response

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8ac90c1bf6e3e3ae24ec38fff5529472?d=identicon&s=25 Flavio Mori (Guest)
on 2009-06-02 23:15
(Received via mailing list)
I want to send a response in a content type that is not listed in the
request Accept header. When I try to do this in Rails a response of
status code 406 Not Acceptable is sent. I would like to know how to do
this.

Ps: A example of a API that do this is the Sun Cloud API, where the
errors are sent in a specific media type (http://kenai.com/projects/
suncloudapis/pages/CommonBehaviors#Data_Models).
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-06-03 08:39
(Received via mailing list)
On Tue, Jun 2, 2009 at 10:33 PM, Flavio Mori <flaviomori@gmail.com>
wrote:
>
> I want to send a response in a content type that is not listed in the
> request Accept header. When I try to do this in Rails a response of
> status code 406 Not Acceptable is sent. I would like to know how to do
> this.
>
> Ps: A example of a API that do this is the Sun Cloud API, where the
> errors are sent in a specific media type (http://kenai.com/projects/
> suncloudapis/pages/CommonBehaviors#Data_Models).

Add :status => 406 to your render call:

  render ..., :status => 406

Andrew Timberlake
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings
This topic is locked and can not be replied to.