DEV Community

Ali Abbas
Ali Abbas

Posted on

Explain PUT and PATCH requests like I'm five

  • PUT
  • PATCH

Top comments (2)

Collapse
 
eimihar profile image
Rahimie Ahmad

In a scenario where they're both used to repair a toy,

PUT

PUT request is like a father buying an exact whole new toy to replace his child's (server) broken toy, except that everytime the toy needs a repair, the father has to buy the exact similar toy.

PATCH

Patch is like a father only having to buy parts of the exact toy.

UPDATE

I don't remember having UPDATE verb in restful.

My Conclusion

The benefit of PUT over PATCH is just about giving the whole updated object/resource. This'll be a good case if you don't mess or deconstruct the object that much.

The benefit of PATCH over PUT is when you have many client controller working on ONLY several fields of one particular object/resource, and you don't want to waste time reconstruct the object details that much. Or you just want to update particular fields, without worrying about the complete object detail (or messing up with it), the client validation etc.

Collapse
 
realabbas profile image
Ali Abbas

Great Explaination DevπŸ‘πŸ––