In the Register
method of the WebApiConfig
class (located in the App_Start
folder) try adding this line:
config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling =
Newtonsoft.Json.DefaultValueHandling.Include;
This should force Web Api to include default values if it isn't already.
EDIT
If you're using an older version of Web API that does not have a WebApiConfig, you can also do this in the Application_Start
method in Global.asax.cs
:
var config = GlobalConfiguration.Configuration;
var jsonSettings = config.Formatters.JsonFormatter.SerializerSettings;
jsonSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;