Print

Print


Ralph LeVan <[log in to unmask]> wrote:

> Where at all possible, I want a true REST interface.  I recognize that
> sometimes you need to use POST to send data, but I've found it very helpful
> to be able to craft URLs that can be shared that contain a complete request.

That's not impossible with REST.  There's a lot of confusion about what
REST actually means, but the IBM article at
https://www.ibm.com/developerworks/webservices/library/ws-restful/ isn't
bad.

A couple of good rules-of-thumb to keep in mind:

1.  URIs name objects; they do not name actions.  So if you've got
    requests like "GET /foo/getAuthors?doc=bar", you're doing it wrong.
    It should be something like "GET /foo/doc/bar?field=authors", or
    even better, "GET /foo/doc/bar/authors".  Once you get this
    straight, the bit about not using GET to side-effect the server sort
    of falls out automatically.

2.  Lots of proxies (mistakenly) don't forward bodies for GET requests.
    So as a practical matter, you can only pass parameters to a GET
    request as a "query string".  POST requests don't have that
    drawback, so if you're passing parameters which can't be expressed
    as a short text string (image searches, for instance, with a query
    image), you'll wind up using POST even if GET is the "correct"
    method.

Bill