Content Negotiation in Spring Boot
Content Negatiation:
- Same Resource - Same URI
- with Same URI we can have different Representations are possible
- we might get Response in JSON format
- some other consumer might expect that response in XML formate
in given below example we have same response just the difference is JSON and XML formate
so one consumer can get in xml or other one can get response in json formate
Example 1 Different Content Type - XML or JSON or ...
Example 2 Different Language - English or Hindi or Urdu ...
Actually your consumer has to tell us which representation they want from us
Q: How can a customer tell the rest api provider what they want as response?
Answer: Content Negotiation
Example 1 : A consumer can use things like Accept Header, i can sent a request , with a mime type of application XML. so i can create accept Header with value application xml
so with the same resource we can have different representations
So with Content Negotiation:
Consumer Tells the Content provider what kind of Representation i would want
Xml Response or Jsoan Response or text back in france or german or english langauage
and This is typicaly done by your Requst Header
Example : to get response represent in XML format
Step 1:
<dependency>
Comments
Post a Comment