Correct HTTP method for RESTful create-or-update?

The HTTP 1.1 specification says for POST:

9.5 POST

The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.

And for PUT:

9.6 PUT

The PUT method requests that the enclosed entity be stored under the supplied Request-URI.

Given that, and the fact that PUT is idempotent and POST is not, PUT seems the logical choice here for both your create and update.

Source:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.2

Leave a Comment

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