Should the representation(html, xml, json) returned by a RESTful web service be determined by the url or by the Accept HTTP header?
Both are valid. Quote from xml.com:
A resource may have more than one representation. There are four frequently used ways of delivering the correct resource representation to consumers: Server-driven negotiation. The service provider determines the right representation from prior knowledge of its clients or uses the information provided in HTTP headers like Accept, Accept-Charset, Accept-Encoding, Accept-Language, and User-Agent. The drawback of this approach is that the server may not have the best knowledge about what a client really wants. Client-driven negotiation. A client initiates a request to a server. The server returns a list of available of representations. The client then selects the representation it wants and sends a second request to the server. The drawback is that a client needs to send two requests. Proxy-driven negotiation. A client initiates a request to a server through a proxy. The proxy passes the request to the server and obtains a list of representations. The proxy selects one representation according to preferences set by the client and returns the representation back to the client. URI-specified representation. A client specifies the representation it wants in the URI query string.
A resource may have more than one representation. There are four frequently used ways of delivering the correct resource representation to consumers:
1.4m articles
1.4m replys
5 comments
57.0k users