I have an Employee table
public class Employee
{
[Key]
public long ID { get; set; }
public DateTime EmpDate { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
I have created web API to post the employee data:
[HttpPost]
public async Task<ActionResult<Employee>> PostLead(Employee employee)
{
//Code to post
}
This is my JSON body
{
"firstname":"xyz",
"lastname":"abc",
"EmpDate":"2019-01-06 17:16:40"
}
I am getting error as The JSON value could not be converted to System.DateTime.
But when I pass EmpDate value as 2019-01-06
, I am not getting an error.