Search code examples
odataolingo

Does OData v2 support POST of a contained entity?


The OData v4 Advanced Tutorial provides an example of creating a Contained Entity.

Create a Contained Entity The request below creates a Trip for Person with UserName 'russellwhyte'. Trips is a contained navigation property for Person.

POST serviceRoot/People('russellwhyte')/Trips

I'm trying to determine if v2 supported this concept of creating a Contained Entity. The v4 What's New docs don't mention Contained Entity as something new.

However, I haven't found mention of this concept in any v2 docs. Perhaps it was added in v3?

If by chance the concept of creating a contained entity existed in Odata v2, does Olingo v2 support it?


Solution

  • Short answer is no.

    Navigations was something that was extensively updated in OData 4. They were always bidirectional in OData 2 and were called Associations.

    The reason you didn't find any information is because you were reading What's new in OData 4.01 rather than What's new in OData 4.0.

    Though if you want to create entities by sending a POST request on a navigation property, you can do that in OData 2 as well as in Olingo 2.

    The catch here is that, as the associations are always bi-directional, you need a corresponding AssociationSet for the navigation property, which will require a corresponding EntitySet.So the entity, created by sending a POST request on the navigating property will not really be an embedded one, and will have a top level URL too.