I don't know exact difference between PATCH and PUT method. Can anyone tell me when we should use this methods with proper example.
I don't know exact difference between PATCH and PUT method. Can anyone tell me when we should use this methods with proper example.
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.
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.