???? PUT vs PATCH in REST Apis
Sahil Anower
Crafting solutions & scalability | 2+ YOE || Java | Spring | Node | AWS | Microservices | Docker
In layman's words, both are used when we want to update a record in the DB, but there is a slight modification in the way how the updation of the record works.
Whenever we are sure that the frontend is passing the whole record in the request body along with the updation fields, then in this case, we should use PUT request. Now, if the request body contains only the updated fields and not all the fields of the record, then here we must use the PATCH request. Let’s understand this with an example:
Thus, it is dependent upon us, what to use while sending update requests, but it is recommended to use PATCH, as it also uses less bandwidth, and also relatively simple to use.