AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

POST endpint that creates a resource and returns it in the body - for `CreatedAtAction` action name should contain GET action not POST Action

Open flamaniac opened this issue 1 year ago • 3 comments

Description

In the examples here: https://learn.microsoft.com/en-us/aspnet/core/web-api/action-return-types?view=aspnetcore-9.0#asynchronous-action-1

the first parameter of CreatedAtAction points to the same method (POST) but in description, it states that the location header will be pointing to the get method.

It is confusing. Shouldn't this be GET like here: https://stackoverflow.com/a/64315534

Page URL

https://learn.microsoft.com/en-us/aspnet/core/web-api/action-return-types?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/web-api/action-return-types.md

Document ID

b51bc104-a6e2-b21f-8362-45cee22e8c22

Article author

@tdykstra

Related Issues


Associated WorkItem - 356818

flamaniac avatar Dec 13 '24 13:12 flamaniac

Where do you see something that indicates

the first parameter of CreatedAtAction points to the same method (POST)

tdykstra avatar Dec 13 '24 19:12 tdykstra

In the example under the link in descriprion .

return CreatedAtAction(nameof(CreateAsync_ActionResultOfT), new { id = product.Id }, product);

Should be "nameof(GetProductAsync)"

Similar to: https://github.com/dotnet/AspNetCore.Docs/issues/34081

flamaniac avatar Dec 13 '24 19:12 flamaniac

You are correct, thanks for reporting this. I'm fixing it in https://github.com/dotnet/AspNetCore.Docs/pull/34390 and https://github.com/dotnet/AspNetCore.Docs.Samples/pull/268

tdykstra avatar Dec 18 '24 19:12 tdykstra