WebAPI and ODataController return 406 Not Acceptable
If you are using OData V4, replace using System.Web.Http.OData; With using Microsoft.AspNet.OData; (Please check the comments for the latest library) in the ODataController works for me.
If you are using OData V4, replace using System.Web.Http.OData; With using Microsoft.AspNet.OData; (Please check the comments for the latest library) in the ODataController works for me.
The solution I ended up using involved MemoryCache in the System.Runtime.Caching namespace. Here is the code that ended up working for caching my collection: //If the data exists in cache, pull it from there, otherwise make a call to database to get the data ObjectCache cache = MemoryCache.Default; var peopleData = cache.Get(“PeopleData”) as List<People>; if … Read more
Actually %27 is not a solution. The correct way to escape is to place two single quotes into the string instead one. In example “o”clock”
OData is a similar specification to JSON API. Both of them describe a standard protocol for creation and consumption of RESTful APIs. GraphQL is a totally different approach to API design and specifies a different way of querying API resources. OData: Designed and developed at Microsoft since 2007, standardized by the OASIS consortium. The latest … Read more
After going through a lot of time on this, I finally got the answer. We can nest select within expand using ; as a separator, something like odata/Products(8)?$expand=choices($select=col1,col2;$expand=item($select=name)) This is documented in the OData v4 $expand documentation. The documentation also lists other useful examples such as Categories?$expand=Products($filter=DiscontinuedDate eq null) Categories?$expand=Products/$count($search=blue)
You can definitely combine predicates in the $filter. For example: /People?$filter=endswith(LastName,’Smith’) and startswith(FirstName,’Mary’) For details around supported operators and such please see this page: http://www.odata.org/documentation/odata-version-2-0/uri-conventions#FilterSystemQueryOption Currently OData doesn’t have a way to express the question “People which have at least one address”. Depending on your data it might be feasible to download all People fulfilling … Read more
UPDATE: At this point in time I would recommend that you follow the solution posted by vaccano, which is based on input from the OData team. What you need to do is to create a new Attribute inheriting from EnableQueryAttribute for OData 4 (or QuerableAttribute depending on which version of Web API\OData you are talking … Read more
i am the author of the library at http://code.google.com/p/odata-py/ it’s still in its early stages but it provides the most basic functionalities (create, read, update). Don’t hesitate to drop a message if you see a bug or want to contribute 😉
Figured this out. OData V2 out-of-the-box returns dates out of SQL in JSON Date format like so: /Date(1338282808000)/ However, in order to use a date as a filter within an OData call, your date has to be in EDM format, looking like this: 2012-05-29T09:13:28 So, I needed to get the date from my initial OData … Read more
From the docs 13.1 Model Bound Attributes: Now the default setting for WebAPI OData is : client can’t apply $count, $orderby, $select, $top, $expand, $filter in the query, query like localhost\odata\Customers?$orderby=Name will failed as BadRequest, because all properties are not sort-able by default, this is a breaking change in 6.0.0 So, we now need to … Read more