What is the difference between the PUT method and PATCH? [duplicate]

10

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?

    
asked by anonymous 04.07.2017 / 18:18

1 answer

10

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:

04.07.2017 / 18:52