Some teach that to upgrade uses PUT
and others teach using PATCH
.
So, what's the difference between the PUT method and PATCH?
When should I use one and the other?
Some teach that to upgrade uses PUT
and others teach using PATCH
.
So, what's the difference between the PUT method and PATCH?
When should I use one and the other?
In a nutshell, the PUT
and PATCH
HTTP methods are used to indicate a request to change data.
Generally, when using PUT
, it is readable that the change in data will be with reference to the complete entity.
Example: (/usuario/1234)
:
Result: {'id': 1234, 'name': 'Joao', 'idade': 25, 'documento': '123.321.12-X'}
PATCH
is used for partial updating, when you do not want to send the full payload.
Example: (/usuario/1234)
:
Result: {'name': 'João'}
References: