Directory Structure-like URIs

by Subbu Allamaraju on November 12, 2008

Alex Rodriguez in RESTful Web services: The basics says:

REST Web service URIs should be intuitive to the point where they are easy to guess. Think of a URI as a kind of self-documenting interface that requires little, if any, explanation or reference for a developer to understand what it points to and to derive related resources. To this end, the structure of a URI should be straightforward, predictable, and easily understood.

What is interesting is that, the example cited in this paper carefully tries to skirt around the problem of how a client can determine what a URI is supposed to do. Well, if the structure of the URI is such that it is self-describing, the problem is solved. Right? Sorry Alex. No. The answer is linking. This is unfortunate, coming from IBM Developer Works.

Here is a more interesting advice:

Instead of using the 404 Not Found code if the request URI is for a partial path, always provide a default page or resource as a response.

I wish he tried to explain this with an example, as that would have allowed him to see the consequences of masquerading errors in success responses.

Leave a Comment

Previous post:

Next post: