When defining a PUT method on a resource is it required/standard/customary to include the entire definition of the resource (i.e. everything needed to create it) or is it also acceptable to send only updated fields?
For example, if I have a resource with 10 attributes including one called quantity and I want to update the quantity to a specified value. Is it acceptable to PUT only the quantity?
What about the other 9 attributes? Assuming each attribute could be updated individually, is it good practice to define the request body simply to have all 10 attributes as optional?
PUT when used RESTfully is intended to replace the entire resource, so you would want to include the full set of attributes.
That said, REST is used rather improperly in most cases anyway, and as long as your API is documented well, you can do whatever you deem most appropriate for your situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With