Prefer http header support in OData v4 Post actions

Topics: ASP.NET MVC, ASP.NET Web API
Feb 16, 2015 at 7:23 PM
The spec says it should return with expand feature during the POST if we pass Prefer header in the request. I couldn’t get this working in OData v4.

http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html

11.4.2.2 Create Related Entities When Creating an Entity
A request to create an entity that includes related entities, represented using the appropriate inline representation, is referred to as a “deep insert”. Media entities, whose binary representation cannot be represented inline, cannot be created within a deep insert.
If the inline representation contains a value for a computed property or dependent property of a referential constraint, the service MUST ignore that value when creating the related entity.
On success, the service MUST create all entities and relate them. If the request included a return __Prefer header with a value of return=representation and is applied by the service, the response MUST be expanded to at least the level that was present in the deep-insert request.
__On failure, the service MUST NOT create any of the entities.