httprestcrudhttp-method

Which HTTP methods match up to which CRUD methods?


In RESTful style programming, we should use HTTP methods as our building blocks. I'm a little confused though which methods match up to the classic CRUD methods. GET/Read and DELETE/Delete are obvious enough.

However, what is the difference between PUT/POST? Do they match one to one with Create and Update?


Solution

  • Create = PUT with a new URI
             POST to a base URI returning a newly created URI
    Read   = GET
    Update = PUT with an existing URI
    Delete = DELETE
    

    PUT can map to both Create and Update depending on the existence of the URI used with the PUT.

    POST maps to Create.

    Correction: POST can also map to Update although it's typically used for Create. POST can also be a partial update so we don't need the proposed PATCH method.