Is using a verb in URL fundamentally incompatible with REST?

This article has some nice tips: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api

Quoting from the article:

What about actions that don’t fit into the world of CRUD operations?

This is where things can get fuzzy. There are a number of approaches:

  1. Restructure the action to appear like a field of a resource. This works if the action doesn’t take parameters. For example an activate action could be mapped to a boolean activated field and updated via a PATCH to the resource.

  2. Treat it like a sub-resource with RESTful principles. For example, GitHub’s API lets you star a gist with PUT /gists/:id/star and unstar with DELETE /gists/:id/star.

  3. Sometimes you really have no way to map the action to a sensible RESTful structure. For example, a multi-resource search doesn’t really
    make sense to be applied to a specific resource’s endpoint. In this
    case, /search would make the most sense even though it isn’t a noun.
    This is OK – just do what’s right from the perspective of the API
    consumer and make sure it’s documented clearly to avoid confusion.

I personally like suggestion #2. If you need to pause something, what are you pausing? If it’s a process with a name, then try this:

/process/{processName}/pause

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)