7 Tweets Jan 31, 2023
Differences between PUT and PATCH
Thread ๐Ÿงต๐Ÿ‘‡
APIs use several HTTP methods but PUT and PATCH are probably the most confusing two.
Both methods are used to modify/update the resources.
Let's talk about the differences between these methods.
The PUT method is a way of modifying resources by sending data that updates the entire resource.
If a resource already exists, PUT will replace it in its entirety. If the resource does not exist, PUT will create it.
Let's say you want to update the user via API.
With the PUT request, we send all the attributes contained in the resource.
In our case:
- first name
- last name
- email
- avatar
As we send all data for the resource PUT method uses more bandwidth than PATCH.
PATCH is a different method of updating the resources.
In this situation, the client sends partial data to be updated without modifying the entire resource.
Fields not contained in the payload will stay unmodified.
In this example, we're sending only email and avatar.
As we send only data that should be updated, PATCH uses less bandwidth than PUT.
Thanks for reading!
Follow us @Rapid_API for more exclusive content. ๐Ÿ™๐Ÿ’™

Loading suggestions...