A PUT request always places one thing in the service.
You need to decide what that one thing is. Two of the choices are:
- The thing is a specific property, and the system has ways of selecting sets of properties.
- The thing is a specific object with a number of properties.
If you select one path, you can easily PUT new properties independently, at the cost of doing many puts when you have many properties to update. There is a risk in this approach, as in a collection of operations, you'll need to monitor and manage every operation was succesfully executed.
If you select the other pat, you can easily PUT new objects, which will always be consistently placed with all properties at the new correct value.
A PATCH request modifies an existing thing
The HTML PATCH verb is a relatively new construct. In this approach, you operate like a PUT, but you only include the portions of the object that have new values. The server receives this request, and will merge the existing object with the request. Typically this is done by locating JSON node above the value, and replacing the node with the new value. For example
Person: {
Age: 5,
Height: 30,
Hobbies: [ 'crayons', 'dancing', 'singing' ]
}
would only replace the Person.Age
, Person.Height
, and Person.Hobbies
values, even if there are also Person.Name
, Person.Weight
, and Person.Gender
properties already in the object at that URL.