What is content negotiation in REST, and how does it work?
- Content negotiation allows clients to specify desired response format.
- Uses HTTP headers:
- Accept: application/json → Request JSON.
- Accept: application/xml → Request XML.
- The server returns response in requested format (if supported).
👉 Example in ASP.NET Core: Add XML formatter with
services.AddControllers()
.AddXmlSerializerFormatters();