???? PUT vs PATCH in REST Apis

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:

No alt text provided for this image
PUT vs PATCH request 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.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了