Announcement Announcement Module
No announcement yet.
Invalid Accept header causes 500 response Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invalid Accept header causes 500 response

    So I have a REST service setup with the ContentNegotiatingViewResolver to transform my responses into either xml or json based on the Accept header. I set the useNotAcceptableStatusCode property to true and it appears to work as expected. If a consumer sends in a request for 'application/pdf' or some other valid media type that is not supported then they get back a 406 status. However, if the Accept header is a completely invalid media type like 'foo' then an exception is thrown and the consumer ends up getting back a 500 Internal Server Error instead of the expected 406.

    Does anyone have any suggestions on how to make it return the proper response when an invalid media type is requested? Or maybe I just need to submit this as a bug/enhancement to the ContentNegotiatingViewResolver?