Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8832

Kentico Web Api - Self referencing loop

$
0
0
I am getting the following error in my custom web apiNewtonsoft.Json.JsonSerializationException: 'Self referencing loop detected for property 'ProviderObject' with type 'CMS.DataEngine.DataClassInfoProvider'. Path '[0].DataClassInfo.TypeInfo.ProviderObject.TypeInfo'.'This is my code string customTableClassName = @customtable.countries@; public HttpResponseMessage Get() { // Gets the custom table //CMS.DataEngine.DataClassInfo customTable = CMS.DataEngine.DataClassInfoProvider.GetDataClassInfo(customTableClassName); // Gets a custom table record with a specific ID (25) var item = CustomTableItemProvider.GetItems(customTableClassName).ToList(); //CustomTableItem item = CustomTableItemProvider.GetItems(23,customTableClassName); try { JsonConvert.SerializeObject(item); // An unhandled exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll // Additional information: Self referencing loop detected with type 'JSONPlayground.Author'.Path 'FavouriteAuthors'. } catch (JsonSerializationException e) { Console.WriteLine(e); } string countrylist = JsonConvert.SerializeObject(item, new JsonSerializerSettings() { PreserveReferencesHandling = PreserveReferencesHandling.Objects, Formatting = Formatting.Indented }); // You can return a variety of things in Web API controller actions. For more details, see http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/action-results return Request.CreateResponse(HttpStatusCode.OK, countrylist); }

Viewing all articles
Browse latest Browse all 8832

Trending Articles