-
|
What’s the difference between PUT and PATCH in a REST API? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
PUT replaces the entire resource with the new data you send, while PATCH only updates the fields you specify, leaving the rest unchanged. |
Beta Was this translation helpful? Give feedback.
-
|
PUT and PATCH are two methods that are often used for updating resources on the server. However, they differ in their approach. PUT For example, let's say you have a user profile with fields for name, email, and password. If you use PUT to update the profile, you’ll have to send the updated values for all three fields: name, email, and password. PATCH So, if you only want to update the email field only, you would send just that field with the new value. The server then applies the changes you specified and leaves the rest of the resource unchanged. |
Beta Was this translation helpful? Give feedback.
PUT replaces the entire resource with the new data you send, while PATCH only updates the fields you specify, leaving the rest unchanged.