O'Reilly logo

RESTful Java Patterns and Best Practices by Bhakti Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Content negotiation

Content negotiation means allowing different representations of a resource in the same URI so that clients can make a choice on what suits them best.

 

"HTTP has provisions for several mechanisms for "content negotiation" - the process of selecting the best representation for a given response when there are multiple representations available."

 
 --RFC 2616, Fielding et al.

There are different patterns for content negotiation. These are as follows:

  • Using HTTP headers
  • Using URL patterns

Content negotiation using HTTP headers

When the client sends requests to create or update a resource, there is some form of payload that should be transferred from the client to the endpoint. Also, when a response is generated, a payload can be sent back ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required