This project is read-only.

OData: POST with $expand, returning entity from PUT

Topics: ASP.NET Web API, General
May 5, 2014 at 12:12 AM
I don't think either of these is possible [at the moment] but here goes:

If I create an entity using POST, I get back the object I just created in terms of its basic properties. Can I specify the format the object that is returned - in particular can I ask for the navigation properties with '$expand'?

Second, if I update an entity with PUT, is there a way to return the updated entity in the same way as above (e.g. using $expand, $select, etc.). At the moment, I just seem to get an empty response. Presumably the assumption is that the entity is now in the state that got sent on the request, but this isn't necessarily the case if, for example, there is a server-side properties such as 'WhenUpdated' that I may be interested in getting back.

Jan 8, 2015 at 9:16 PM
I found, at least with OData 2.2 for v4, that I could add [EnableQuery] to a POST and get expand to work. Request looks like POST /odata/Foos?$expand=Bar

Multi level expand worked too. POST /odata/Foos?$expand=Bar($expand=OtherBar)

Returned results need to be an entity since currently a complex type can not contain an entity.