0

when I try to get data from my API on IIS this error is shown

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'."

this error is shown in my localhost also but when I wrote this code

var json = config.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
config.Formatters.Remove(config.Formatters.XmlFormatter);

the error is gone and the localhost is working fine right now,

http://192.168.137.1:5020/api/prodects

no data back just error

http://localhost:54740/api/prodects

data back and everything is fine

What am I missing?

Cleptus
  • 3,446
  • 4
  • 28
  • 34
  • What does this *question* have to do with SQL Server? – Thom A Oct 02 '19 at 09:30
  • In which platform you run your code ? asp.net. xamarin, xamarin.forms or something else ? – nzrytmn Oct 02 '19 at 09:58
  • Check https://stackoverflow.com/questions/23098191/failed-to-serialize-the-response-in-web-api-with-json https://stackoverflow.com/questions/12641386/failed-to-serialize-the-response-in-web-api – ColeX Oct 02 '19 at 12:01
  • i run the code in asp.net api for xamarin application – ans bedoor Oct 02 '19 at 12:19
  • the question with sql server that i have another error show with the error the previous error .. Cannot open database \"GdgShopDB\" requested by the login. The login failed.\r\nLogin failed for user 'WORKGROUP\\DESKTOP-6GP9QOH$'." – ans bedoor Oct 02 '19 at 12:21

0 Answers0