REST API throws exception on items with nested content
I can't get content item through PublishedContentController of REST API if such item contains Umbraco.NestedContent property. Even if nested content type has no properties or has any number of any type properties. The only way when REST API works if property is null or empty array.
I'm using empty Asp.NET web application, UmbracoCms 7.7.8, and UmbracoCms.RestApi 0.9.0.
The exception in response:
{
"Message": "An error has occurred.",
"ExceptionMessage": "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": null,
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Self referencing loop detected for property 'nestedProperty' with type 'System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent]'. Path 'properties.nestedProperty[0].contentSet[0]'.",
"ExceptionType": "Newtonsoft.Json.JsonSerializationException",
"StackTrace": " в Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n ..."
}
}
But when I'm requesting same data through ContentController, there are no errors and nested property returns correctly with json-serialized data. Example below:
REST API throws exception on items with nested content
I can't get content item through PublishedContentController of REST API if such item contains Umbraco.NestedContent property. Even if nested content type has no properties or has any number of any type properties. The only way when REST API works if property is null or empty array.
I'm using empty Asp.NET web application, UmbracoCms 7.7.8, and UmbracoCms.RestApi 0.9.0.
The exception in response:
But when I'm requesting same data through ContentController, there are no errors and nested property returns correctly with json-serialized data. Example below:
I tested it on empty SqlCe database project.
Does anyone knows why is this happening and how to make PublishedContentController work?
Link to github
Did you find a solution for this ? :)
is working on a reply...