when you want to update a resource with PUT request, you have to send the full payload as the request whereas with PATCH, you only send the parameters which you want to update.
Suppose we have a resource that holds the first name and last name of a person.
If we want to change the first name then we send a PUT request for Update
{ "first": "Joseph", "last": "Maria" }
Here, although we are only changing the first name, with PUT request we have to send both parameters first and last. In other words, it is mandatory to send all values again, the full payload.
When we send a PATCH request, however, we only send the data which we want to update. In other words, we only send the first name to update, no need to send the last name.
For this reason, PATCH request requires less bandwidth.
No comments:
Post a Comment