Search code examples
kendo-uiodataasp.net-web-api2

Visual Studio 2012 Odata Endpoint Issue


I'm builing an Odata end point with WebApi 2 and Visual Studio 2012, using the ODataController. The end point works but the data is clearly v4 format while the DataServiceVersion is 3.0. In fact, it looks a lot like the output of this Microsoft post. This post seems to have the same issue, it clearly uses [odata.] and [value] instead of __count and results. My front end is a Telerik datasource and it doesn't know what to do with the mismatch. What can be done to resolve this?

http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint


Solution

  • OData WebbAPI V3 supports Json Light and Json Verbose both. Accept:application/json would returns Json light, which make it look same as V4, but in fact it is still v3. Seems you would like return json verbose, then you can set the header to Accept:application/json;odata=verbose.

    You can check the bottom of the post. http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint