I don't know exact difference between PATCH and PUT method. Can anyone tell me when we should use this methods with proper example.
-
Does this answer your question? [PUT vs. POST in REST](https://stackoverflow.com/questions/630453/put-vs-post-in-rest) – Sehdev Feb 23 '20 at 04:17
-
Question is: When use PATCH and PUT NOT difference between POST and PUT !!! Please, delete "This question already has answers here:"... – Boss COTIGA Mar 14 '22 at 22:28
-
This question is a duplicate, but of this [one](https://stackoverflow.com/questions/28459418/use-of-put-vs-patch-methods-in-rest-api-real-life-scenarios?rq=1) not the one linked. – Islam Hassan Jun 03 '22 at 14:47
2 Answers
Put is when you update the whole model and use patch when you want to update a portion or single attribute. For instance, a user may have a username they change that is stored on the user model. You would patch just the username when they change it. If you would like to replace the whole user model with a new user model you would use a put request.

- 921
- 1
- 6
- 17
Patch updates a piece of a record. Put replaces it altogether. However, there's nothing stopping you from 'misusing' the methods in whatever way you see fit. There's also another incarnation of Patch called "Json-patch", which dictates how to communicate changes rather than just values. Unlike regular Patching, this offers the ability to update aspects of nested records rather than replace them wholesale.

- 2,659
- 1
- 19
- 20