Reputation: 634
If I want to code a REST Service that returns either Json or Xml depending on the requester's headers, should their request of application/json
be added to the Accept
Header or the Content-Type
Header (or both)?
Upvotes: 0
Views: 45
Reputation: 56
Your consumer specifies the media types which are acceptable for the response in the Accept
header.
You can then send the data using the appropriate media type.
If they are sending you data - for example in a POST
, they must populate the Content-Type
header with the media type of the data they are sending.
Upvotes: 1