Recovery Web Services

What should you avoid when setting up the Restful interface to make sure you haven't turned it into an RPC?

+6
rest
source share
5 answers

do:

  • Build your application as hypertext-driven (Hypermedia as the application state engine - HATEOAS).
  • Spend most of your time and effort identifying resources and creating media types to represent them.
  • Think of all the URIs as a resource identifier and assume that it will change in the future.
  • Provide all options for further promotion through your application as links in your presentation.
  • Think of your application as a website that will be “crawled” or “viewed” by customers.
  • Try writing a client for your API and see where the connection occurs.

Not

  • Publish URI patterns in the API documentation. If you must have templates for query parameters, for example, make sure they are part of your media type definition.
  • Think of your application as a set of URIs with four verbs.
  • Provide clients with mime types, such as "application / xml" or "application / json".

To use the analogy, your API should work more like GPS for your customers and less like a map. You will only provide customers with the name of a nearby street. But from now on, they can only do what your application says, what they can do at any time.

The goal of this style is to minimize the connection between your application and its clients. All communication should be done in determining your media type. This simplifies the evolution of the API and provides a good mechanism for version control. He also asks questions about issues such as pagination.

Most RESTful APIs do not match this pattern. For what it does, see the Sun Cloud API and backstory .

+8
source share

Use a basic protocol whenever possible. Instead of having verbs in your payload, try using (for example) the HTTP GET, POST, PUT, DELETE methods. Your URI should describe the resource, but not do with it.

+4
source share

Some of the things you want to avoid:

  • Ignoring Caching
  • Tunneling everything through GET (or, alternatively, POST)
  • Ignoring MIME Types

There's a nice article that talks about some anti-REST patterns:

http://www.infoq.com/articles/rest-anti-patterns

+3
source share

Kind of a broad question, but I'll try. First, use only HTTP verbs as they were intended. Do not send POST to the URL with the url argument, which basically overrides POST and turns it into GET or DELETE. This is how SOAP works (it's all POST).

+2
source share

This article describes some design decisions that distinguish RPC from REST:

http://www.pluralsight.com/community/blogs/tewald/archive/2007/04/28/47067.aspx

@ S.Lott: thanks, I honestly thought I posted this as an answer, not a comment. I'm losing marble.

+2
source share

All Articles