I'm attempting to migrate a WebAPI-based app from WebAPI RC to the release version. It takes in some query parameters, and returns ATOM-formatted OData. Since it's a running service, I need to maintain the current behavior.
I've changed the API methods to return a PageResult<T>
with my data in it. According to the Supporting OData Query Options article on MSDN that should be all I need to do, but it's not working. I get the result, but it's always formatted as JSON. I've tried changing the Accept
request header to application/atom+xml
, but it doesn't seem to make any difference.
I've also tried adding the following lines in my WebApiConfig
to no apparent effect:
configuration.EnableQuerySupport();
configuration.Formatters.InsertRange(0, ODataMediaTypeFormatters.Create());
I tried clearing out the existing formatters, just to see what would happen. I just get back 406 Not Acceptable
errors. So it seems like perhaps the OData formatters are not reporting that they can handle the request/response?
Queryable
([Queryable(AllowedQueryOptions = AllowedQueryOptions.All)] ) attribute to your controller method and set it's return type toIQueryable<T>
? Maybe you could post your controller and global.asax code. – DaveBIQueryable<T>
because I need to return a $skiptoken, and my understanding is that you can't do that with anIQueryable<T>
. Hence use ofPageResult<T>
instead. My function code is irrelevant, lots of proprietary data access. I can repro the problem with a dummy method that just returnsnew PageResult<string>(new List<string>(), null, null)
– Brian Reischl