OData / WebApi

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

UpdatedODataResult return 204 HttpStatus as default #1260

Open davidhjones opened 6 years ago

davidhjones commented 6 years ago

By default, UpdatedODataResult is returning an http status of 204. It should return 200 by default and 204 if requested.

Assemblies affected

OData WebApi lib 7.3.1

Reproduce steps

// PUT: api/v1/Applications('5')
[HttpPut]
[ODataRoute("({applicationId})")]
public IActionResult Put([FromODataUri] string contextId, [FromODataUri] string applicationId, [FromBody]ApplicationIn applicationIn)
    {
    Application app = new Application
        {
        Created = DateTime.UtcNow,
        Modified = DateTime.UtcNow,
        Name = "NewName",
        Version = "NewVersion"
        };
    return Updated(app);
    }

Expected result

HttpStatus of 200 is returned with the body consisting of the updated entity.

Actual result

HttpStatus of 204 is returned with an empty body

Additional detail

Should operate exactly like CreatedODataResults, except rather than 201 default, should be a 200 default for updated entity.

davidhjones commented 6 years ago

I see the implementation. Seems like the current strategy is an opt-in approach, where 204 / no content returned is the default (if no header is provided). This seems counter-intuitive, but if I understand correctly, changing to an opt-out approach (return 200 and entity) by default would be a breaking change? If there is not intention of changing the strategy to "fix" this issue, then it can be closed.