Reputation: 3153
I have an ODataController which seems to work fine if I just do a GET through my browser. But when I use JayData to read I get a 500 back. I can see GetItems() being called in my ODataController and it returns a valid list of Items. I but I am seeing a handful of ODataContentTypeException exceptions being thrown which have the follwing message:
Additional information: A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/atom+xml;type=feed, application/atom+xml, application/json;odata=verbose, application/json' matches the content type 'application/json; odata=fullmetadata; charset=utf-8'.
Then
Additional information: A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/atom+xml;type=feed, application/atom+xml, application/json;odata=verbose, application/json' matches the content type 'application/json; odata=fullmetadata; charset=utf-8'.
Then
Additional information: A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/xml, application/json;odata=verbose, application/json' matches the content type 'application/json; odata=fullmetadata; charset=utf-8'.
And lastly
Additional information: A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/xml, application/json;odata=verbose, application/json' matches the content type 'application/json; odata=fullmetadata; charset=utf-8'.
I am assuming these are the cause of the 500 I am getting back, but there doesnt' seem to be a way to be sure. According to Chrome, the request being sent is requesting the following:
Accept:application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, /;q=0.1
Accept-Encoding:gzip,deflate,sdch
An empty response with a 500 error is all that is received back. Anyone else having this trouble?
Accept-Language:en-US,en;q=0.8,en-CA;q=0.6
Upvotes: 3
Views: 360
Reputation: 3153
In order for this solution to make sense more info is needed: Using MVC5, with WebAPI 2.0, and the OData nuget package version 5.0
For some reason JayData is trying to use OData v2. So to fix it, I dug through the source code and found that you can specify V3.
Change the configuration of your context to include maxDataServiceVersion: "3.0".
From this:
dbContext = new MyEntities({ name: 'oData', oDataServiceHost: '/odata' }));
To this:
dbContext = new MyEntities({ name: 'oData', oDataServiceHost: '/odata', maxDataServiceVersion: '3.0' }));
And that works for me.
It would be nice if JayStack would document the configuration options available.
Upvotes: 4