Sign In/My Account | View Cart  
advertisement

Article:
 How to Create a REST Protocol
Subject: PUT is not an update
Date: 2004-12-06 08:18:12
From: jdodds
Response to: PUT is not an update

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?


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


Titles Only Titles Only Oldest First
  • PUT is not an update
    2004-12-06 08:40:12 jgregorio [Reply]

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


    The best you can say is that POST isn't defined for an employee by this article. Then again neither is OPTIONS, or LOCK, or any of the other methods you could apply. It does mean that a later spec or article could come along and define what it means to POST to an employee.



Sponsored By: