.NET Web API and OData: Cannot serialize a null ‘feed’

.NET Web API and OData: Cannot serialize a null ‘feed’

Recently I came across an error when working with oData and web API.

Cannot serialize a null ‘feed’.
System.Runtime.Serialization.SerializationException

I couldn’t really find a solution online, but it turns out i just forgot to decorate my method parameter with [FromODataUri].

[EnableQuery]
public IQueryable Get([FromODataUri] ODataQueryOptions queryOptions)
{
...
}

Now you can use $expand and $select in your URL without issues.

Leave a Reply

Your email address will not be published. Required fields are marked *