Reputation: 527
What do you need to avoid in setting up a Restful interface to make sure you have not turned it into an RPC?
Upvotes: 6
Views: 698
Reputation: 29014
Do:
Don't:
To use an analogy, your API should work more like a GPS for your clients and less like a map. You'll only provide clients with the name of a nearby street. But from then on, they can only do what your application says they can do at any given point.
The purpose of this style is to minimize coupling between your application and its clients. All of the coupling should occur in your media type definition. This simplifies the evolution of the API, and provides a nice mechanism for versioning. It also makes questions about issues such as pagination disappear.
Most "RESTful" APIs don't follow this pattern. For one that does, see the Sun Cloud API and its backstory.
Upvotes: 8
Reputation: 403581
This article details some design decisions that differentiate RPC from REST:
http://www.pluralsight.com/community/blogs/tewald/archive/2007/04/28/47067.aspx
@S.Lott: thanks, I honestly thought I'd posted that as answer not a comment. I'm losing my marbles.
Upvotes: 2
Reputation: 63734
Some of the things you want to avoid are:
There's a good article here that talks about some of the REST anti-patterns:
http://www.infoq.com/articles/rest-anti-patterns
Upvotes: 3
Reputation: 1202
Take advantage of the underlying protocol where possible. Instead of having verbs in your payload try to use (for example) the HTTP GET, POST, PUT, DELETE methods. Your URI should describe a resource but not what to do with it.
Upvotes: 4
Reputation: 9855
Kind of a broad question but I'll give it a try. For one, only use the HTTP verbs how the were intended. Don't POST to a URL with a url argument that basically overrides the POST and turns it into a GET or DELETE. This is how SOAP works (everything is a POST).
Upvotes: 2