Yianni
EFCore: don't require primary key for POST
Howdy, forgive me if I don't have the terminology down yet, I just started following this guide recently: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-8.0&preserve-view=true&tabs=visual-studio
So I've created a Model:
And here's my code for the Controller. Note that I am assigning the primary key within this method.
My problem is that I do not want the primary key (Guid) to be required in the request body to send the POST request. Is there any way around this?
I just want my POST request body to look like the following example:
Omitting the Guid from this results in the following error:
"JSON deserialization for type 'api.Models.User' was missing required properties, including the following: guid"
13 replies