Skip to content

[Protocol] HTTP Status Code 500 occured when requesting non-existing entity #115

@karataliu

Description

@karataliu

500 Exception was thrown with NRE

Request:

GET http://localhost:18384/api/TripPin/Airlines('AA') HTTP/1.1

Response

HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true
Server: Microsoft-IIS/8.0
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?RDpcZ2l0XHRcUkVTVGllclx0ZXN0XE9EYXRhRW5kVG9FbmRUZXN0c1xNaWNyb3NvZnQuUmVzdGllci5XZWJBcGkuVGVzdC5TZXJ2aWNlcy5UcmlwcGluXGFwaVxUcmlwUGluXEFpcmxpbmVzKCdBQScp?=
X-Powered-By: ASP.NET
Date: Fri, 17 Jul 2015 05:19:45 GMT
Content-Length: 1946

{
  "error":{
    "code":"","message":"An error has occurred.","innererror":{
      "message":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata.metadata=minimal; odata.streaming=true'.","type":"System.InvalidOperationException","stacktrace":"","internalexception":{
        "message":"Cannot serialize a null 'entry'.","type":"System.Runtime.Serialization.SerializationException","stacktrace":"   at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)\r\n   at System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)\r\n   at Microsoft.Restier.WebApi.Formatter.Serialization.ODataDomainEntityTypeSerializer.WriteObject(Object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext) in d:\\git\\t\\RESTier\\src\\Microsoft.Restier.WebApi\\Formatter\\Serialization\\ODataDomainEntityTypeSerializer.cs:line 45\r\n   at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)\r\n   at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()"
      }
    }
  }
}```

<!---
@huboard:{"custom_state":"archived"}
-->

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions