I am receiving a JSON from the request and able to bind to the model successfully, But when the value of any property in JSON is null, the model fails to bind. Below is my code
public class JobDetails
{
[Required]
[Range(1, int.MaxValue, ErrorMessage = "TransactionId value must be greater than zero")]
public int Id { get; set; }
public string details{ get; set; }
}
[HttpPost]
[Route("create/job")]
public async Task<IActionResult> Add([FromBody]JobDetails model)
{
//when i debug model is null. Expected result {Id:null,details:"some data"}
}
input json
{Id:null,details:"some data"}
Any idea of how to make this work?