Can\'t pass ModelState validation in WebApi application for object which contains nullable types and has null values. The error message is \"The value \'null\' is not valid
I just did a quick test in one my own WebAPI projects and passing null as a value for a nullable value-type works fine. I suggest you inspect the actual data that is being send to your server using a tool like Fiddler
Two valid scenarios that will work are:
{ IntProperty: 1, DateProperty: null }
{ IntProperty: 1 } // Yes, you can simply leave the property out
Scenarios that will NOT work are:
{ IntProperty: 1, DateProperty: "null" } // Notice the quotes
{ IntProperty: 1, DateProperty: undefined } // invalid JSON
{ IntProperty: 1, DateProperty: 0 } // Will not be properly interpreted by the .NET JSON Deserializer
If the two default scenario's do not work then I suspect your problem lies elsewhere. I.e. Have you changed any of the default settings of the JSON serializer in your global.asax?