2

Closed

ODataMediaTypeFormatter is case sensitive causing error during formatting

description

I receive the error below when accessing my People Feed at: http://localhost:51155/api/people If I capitalize 'People' ie: http://localhost:51155/api/People, it works just fine.

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code/>
<m:message xml:lang="en-US">An error has occurred.</m:message>
<m:innererror>
<m:message>
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/atom+xml; charset=utf-8'.
</m:message>
<m:type>System.InvalidOperationException</m:type>
<m:stacktrace/>
<m:internalexception>
<m:message>
The related entity set could not be found. The related entity set is required to serialize the payload.
</m:message>
<m:type>
System.Runtime.Serialization.SerializationException
</m:type>
<m:stacktrace>
at System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.<>c__DisplayClass8.<WriteToStreamAsync>b__7()
at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
</m:stacktrace>
</m:internalexception>
</m:innererror>
</m:error>
Closed May 2, 2013 at 8:25 PM by raghuramn

comments

HongmeiG wrote Apr 1, 2013 at 6:45 PM

Can you take a look to see if this can be fixed at our layer or this is limited by ODataLib?

raghuramn wrote May 2, 2013 at 8:24 PM

OData protocol itself is case sensitive. Entity set names are case sensitive. So, this is expected to fail. That said, we used to throw a very bad error (HTTP status 500) as the bug description shows. We have a better error now - a 404 Not Found.

There is a different bug tracking making the OData uri's case insensitive. You can find it here - https://aspnetwebstack.codeplex.com/workitem/366.

I am closing this and we will use that bug to track as it has more votes.