Update resources through navigation properties pos

2019-07-30 14:45发布

问题:

I have a resource A that has a navigation property that points to resource B. The schema looks like this:

Resource A:

  • ID
  • B (this is a one-to-many navigation property)

Resource B:

  • ID
  • Property1
  • Property2

Can I update values of resource B (i.e. update property1 and property2 of B) through the navigation link of A? In other words, can I say A.B[5].Property1 = x?

In the OData spec and examples, I only see descriptions of modifying which instance of B is associated with A (i.e. modifying /A(0)/$links/B), but not whether or not I can do a PUT/MERGE to /A(0)/B(2) and modify B itself.

回答1:

You should be able to send a PUT request to /A(0)/B(2) and modify properties of B.