Reputation: 31
Our web service only supports JSON. We respond with JSON if we can or respond with an HTTP Error 406: Not acceptable if the client asks application/xml... Is it still considered RESTful?
Upvotes: 3
Views: 525
Reputation: 16316
Well the first question is, does it matter if it's not RESTful? As long as the API is well documented and works for the people who need to use it, I'm not sure this is a concern.
Secondly, REST has less to do with the content of the requests and responses and more to do with how the requests are made. REST in HTTP usually means each API call uses the correct HTTP method to respond to something, and that the URL's are representative of something as well.
For example:
For example, if your API had a single URL endpoint, and the method was chosen by something inside the POST data, then it's probably not RESTful. On the other hand, if each URL represented a resource, and the API was used by traversing URL's, and that anything that changed something used POST/PUT and anything that queried something used GET, it's what most would consider to be RESTful.
Upvotes: -1
Reputation: 57899
REST is not inherently XML-oriented.
Any media type can be a resource.
You just need to declare the media type in the HTML Content-Type header.
Upvotes: 1
Reputation: 12650
You don't have to offer an xml format, but be prepared to deal with annoyed developers. If you want your API to be widely used, you should try and keep developer ecosystem happy.
Upvotes: 1
Reputation: 27235
Personally, I would still consider it RESTful. But that may just be an opinion.
It really depends on your audience. If they do not demand an XML interface, I see no reason to provide one. But if you are attempting to provide the largest range of support and clients, you may want to consider adding XML support.
I have a RESTful API that only provides JSON and I have no intention of providing XML.
Upvotes: 0
Reputation: 700152
Yes. The REST principles builds on the original intentions of the HTTP protocol. There is no requirement to use XML. Actually, XML didn't even exist when HTTP was created...
Upvotes: 8