Sign In/My Account | View Cart  
advertisement

Article:
 How to Create a REST Protocol
Subject: PUT is not an update
Date: 2004-12-03 04:58:54
From: jgregorio
Response to: PUT is not an update

To quote from RFC 2616:


On POST[1]: " Extending a database through an append operation."


On PUT[2]: " The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server."


[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5
[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6


No Previous Message Previous Message Move up to Parent Message Up Next Message Next Message


Titles Only Full Threads Newest First
  • PUT is not an update
    2004-12-06 08:18:12 jdodds [Reply]

    HTTP was originally created for managing collections of documents.


    PUT is intended to be used for adding new documents. A PUT only becomes an 'update' when the specified document already exists. PUT can effectively be both CREATE and UPDATE.


    POST is really much more general than either a CRUD CREATE or a PUT. (Joe, I think you did yourself a disservice with the quote that you pulled from section 9.5 of the HTTP spec.)


    There is, however, a more subtle point that isn't explicit in the article. From section 9.6:


    "The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource."


    While I tend to disagree with the CRUD table in the article, I don't have the same issue with the final table which shows the protocol and reflects that a POST as CREATE is performed against the 'All Employees' collection and the PUT as UPDATE is performed against a specific 'employee'.


    I do have one question: What does it mean to POST to an employee?


Sponsored By: