Mark Baker wrote: > On 11/24/06, Dennis Sosnoski <[EMAIL PROTECTED]> wrote: > >> ... AFAIK anything >> that involves URLs with a bunch of parameters at the end is not REST >> (because it's not identifying a particular resource, it's effectively >> exposing a method call). >> > > If you mean that one of the parameters is an operation, that is > actually RESTful if you're only using GET. > This seems like one of those having-your-cake-and-eating-it-too points. But perhaps I'm misunderstanding the principles of REST. My understanding was that each resource is supposed to be exposed as a URI, and that operations are supposed to be done using the URIs. If you instead use a generic URI and string on parameters to say what you want done, how is that RESTful?
Here's an example, using the much-lauded "REST" API for Amazon: http://xml.amazon.com/onca/xml3?mode=books&AsinSearch=0079132480&type=heavy&page=1&f=xml&t=AssociatesIDwebservices-20&dev-t=XXX (where XXX is the appropriate Amazon associate id). This returns information about a particular book in a particular format. Of course, changing the order of the glob of parameters at the end: http://xml.amazon.com/onca/xml3?mode=books&type=heavy&page=1&f=xml&t=AssociatesIDwebservices-20&dev-t=XXX&AsinSearch=0079132480 returns almost the same result (only almost, in the case of Amazon, because they embed a RequestID in the result). Now where is the resource here? I guess it would have to be Amazon itself, since nothing else is actually identifiable. One might think that an individual book would be a resource, but it's not - at least in this "REST" interface. Interestingly, in the normal HTML Web view of Amazon it actually is, at least to a degree - a search on this ISBN takes you to: http://www.amazon.com/Inside-Java-Virtual-Machine-Masters/dp/0079132480/sr=11-1/qid=1164491543/ref=sr_11_1/103-4485742-1843022 Ignoring the query-dependent garbage at the end, the first part of this is a reasonable resource identification. You can even strip off the garbage and get the same page, using only the resource identification part of the URL: http://www.amazon.com/Inside-Java-Virtual-Machine-Venners/dp/0071350934/ So if the Amazon GET-based XML interface is indeed RESTful, it certainly seems much less RESTful than the conventional HTML Web interface. Both interfaces are structured in a way which by default negates one of the major claimed benefits of a REST approach, that of being able to cache results, but the HTML one at least allows you to access resources directly. The only RESTful part of the GET-based XML interface seems to be that it *does* use "GET" rather than "POST" - but I can't see any advantage provided by this, aside from making it easier for users to generate requests as text strings (which is not one of the claimed benefits of REST, AFAIK). - Dennis
