According to the spec:
The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server.
So if I have to implement a RESTFul service to change the age of a Person:
id: 100, name: John Doe, description: Tall, age: 40
to age 60, should my PUT request contain
id: 100, name: John Doe, description: Tall, age: 60
or just
age: 60
Should the server be expected to merge and update just what changed or completely delete and r开发者_开发问答e-add the resource?
PUT replaces. If you want to just modify part of the resource, use PATCH (or assign separate URIs to the individual aspects of the resource)
精彩评论