Junior — Middle
Have you had experience using the PATCH method for resource updates?
sobes.tech AI
Answer from AI
Yes, the PATCH method is used for partial updates of a resource on the server. Unlike PUT, which usually replaces the entire resource, PATCH allows you to send only the fields that need to be changed. This is convenient when only a small part of the data needs to be updated.
Example of a PATCH request using curl:
curl -X PATCH https://api.example.com/users/123 \
-H "Content-Type: application/json" \
-d '{"email": "newemail@example.com"}'
The server will update only the email field of the user with id 123, without affecting other data.