What is the difference between the PUT method and the PATCH?

Asked

Viewed 10,486 times

13

Some teach that to upgrade uses the PUT and others teach using the PATCH.

So, after all, what is the difference between the PUT method and the PATCH?

When I must wear one and the other?

  • I believe the question linkAnswer your question now =)

  • 2

    I do not believe to be duplicate, the answer in the linked question is rather has vague answers (of course explaining a method by one would be exaggeration in it), by the lack of details there I find it totally valid to formulate a question on the "specific subject", the community will benefit if the answers have examples of the "Verb" structure and explanation of how the process occurs in both. ;)

  • @LINQ I believe the question is not duplicated. The linked question asks all methods and does not bring the difference between PUT and PATCH. And it also doesn’t give examples of how to use.

  • @All right. That’s what "possible" is for. But following: the linked question shows yes the differences between one and the other, it explains what is one and what is the other, in this we can see the differences. I did not understand the question of examples, you want to know at what time to use one or the other?

  • In some places of semantic web I saw talking to use only the methods GET, DELETE, POST and PUT

1 answer

18


In a nutshell, the HTTP methods PUT and PATCH are used to indicate a data change request.

Generally, when using the PUT, it is legible that the change of the data will be with reference to the complete entity.

Example: (/usuario/1234) :

Upshot: {'id': 1234, 'name': 'Joao', 'idade': 25, 'documento': '123.321.12-X'}

The PATCH is used for partial update when you don’t want to send the full payload.

Example: (/usuario/1234) :

Upshot: {'name': 'João'}

References:

  • PUT: the origin server can create the Resource with that URI.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.