According to HTTP terms, The PUT
request is just-like a database update statement.
PUT
- is used for modifying existing resource (Previously POSTED). On the other hand the PATCH
request is used to update some portion of existing resource.
For Example:
Customer Details:
// This is just a example.
firstName = "James";
lastName = "Anderson";
email = "[email protected]";
phoneNumber = "+92 1234567890";
//..
When we want to update to entire record ? we have to use Http
PUT
verb
for that.
such as:
// Customer Details Updated.
firstName = "James++++";
lastName = "Anderson++++";
email = "[email protected]";
phoneNumber = "+92 0987654321";
//..
On the other hand if we want to update only the portion of the record not the entire record then go for Http
PATCH
verb
.
such as:
// Only Customer firstName and lastName is Updated.
firstName = "Updated FirstName";
lastName = "Updated LastName";
//..
PUT VS POST:
When using PUT
request we have to send all parameter such as firstName, lastName, email, phoneNumber Where as In patch
request only send the parameters which one we want to update and it won't effecting or changing other data.
For more details please visit : https://fullstack-developer.academy/restful-api-design-post-vs-put-vs-patch/