DEV Community

NDAYISHIMIYE Espoir
NDAYISHIMIYE Espoir

Posted on

The Difference between HTTP PATCH and PUT methods

PUT and PATCH might be doing the same thing of updating a resource at a location, but they do it differently

What is PUT?
PUT is a method of modifying resource where the client sends data that updates the entire resource. It is used to set an entityโ€™s information completely. PUT is similar to POST in that it can create resources, but it does so when there is a defined URI. PUT overwrites the entire entity if it already exists, and creates a new resource if it doesnโ€™t exist.

For example, when you want to change the first name of a person in a database, you need to send the entire resource when making a PUT request.

Unlike PUT, PATCH applies a partial update to the resource.

This means that you are only required to send the data that you want to update, and it wonโ€™t affect or change anything else. So if you want to update the first name on a database, you will only be required to send the first parameter; the first name.

Top comments (0)