OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
854 stars 475 forks source link

Consistent handling of Null Values #50

Closed LianwMS closed 7 years ago

LianwMS commented 9 years ago

According to OData V4 spec, requesting an entity that doesn't exist (i.e., ~Customers('key-that-does-not-exist') should return 404 (we do this today) but requesting a single-valued (non-collection) entity, property, nav property, or function result should return 204 (no content) if the value is null. In V3 I believe we return null values for properties and function results.

e.g., now in webapi.odata, we have handle logic for raw value as a reference:

if (IsRawValueRequest(request) && response.IsSuccessStatusCode)
{
ObjectContent content = response.Content as ObjectContent;
if (content != null && content.Value == null)
{
actionExecutedContext.Response = request.CreateResponse(HttpStatusCode.NotFound);
}
}

Work Item Details

Original CodePlex Issue: Issue 1602 Status: Proposed Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jan 6, 2014 at 7:24 AM Reported by: cysu Updated on: Jan 6, 2014 at 7:24 AM Updated by: cysu