Search code examples
odata

PATCH collection with ODATA


Using the ODATA standard is it possible to patch an entity property collection by sending just the new item? And what is the result returned?

It could be something like

PATCH Persons/1/Addresses {"city": "SF", "country": "US"}

What should it return? A Person or Address?


Solution

  • According to odata v4 protocol, collection property is treated as a unity, and does not support partially update.

    See Update a Collection Property

    A successful PUT request to the edit URL of a collection property updates that collection. The message body MUST contain the desired new value, formatted as a collection property according to the specified format. The service MUST replace the entire value with the value supplied in the request body. Since collection members have no individual identity, PATCH is not supported for collection properties.

    You can need to use PUT request in this case, both request and response payloads should be the whole collection.