What is the use of Accept and Content-Type Headers in HTTP Request?

Technology CommunityCategory: API DesignWhat is the use of Accept and Content-Type Headers in HTTP Request?
VietMX Staff asked 3 years ago
  • Accept headers tells web service what kind of response client is accepting, so if a web service is capable of sending response in XML and JSON format and client sends Accept header as application/xml then XML response will be sent. For Accept header application/json, server will send the JSON response.
  • Content-Type header is used to tell server what is the format of data being sent in the request. If Content-Type header is application/xml then server will try to parse it as XML data. This header is useful in HTTP Post and Put requests.