sbarnby71
sbarnby71

Reputation: 634

Correct HTTPHeader to set when asking for Json or Xml data to be returned

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

Answers (1)

manp
manp

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

Related Questions