Tuesday, January 13, 2015

Web API error: The 'ObjectContent`1' type failed to serialize the response body for content type...

To solve this error:














Add this code in Global.asax >> Application_Start method:

1
2
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

No comments:

Post a Comment