I'm trying to bind a class object from an endpoint that contains an Enum :-
Sample
public class Person
{
public string Name { get; set; }
public Gender Gender { get; set; }
}
public enum Gender
{
Male = 0,
Female = 1,
}
The Action Signature is as follows :-
public async Task<IHttpActionResult> GetTest([FromBody] Person person)
When the Action method is hit with the folowing object on the body of the request, model binding fails :-
{
"Name": "Derek",
"Gender": "Male"
}
Model binding does work, where i pass the value in via the uri for the enum, but that's not what i want to achieve here.
Do i need to create type converters or is there something simple i'm missing?
"Gender": 0?