Search code examples
c#nestedcloudkenticokentico-kontent

JSON response does not include the Nested content for a particular class


I am working with Kentico Cloud using KenticoCloud DeliveryClient. The issue is that I am loading the data for NewsArticle which include BodyContent. The BodyContent has some InlineContentItemData supposed to be resolved by Resolvers. I added PartnerList (item which includes several Partner items), Carousel (item which includes several ImageGridItem items) and some HTML text.

Here is the code to make the request:

var response = await Client.GetItemsAsync<NewsArticle>(
    new EqualsFilter("system.type", "news_article"),
    new OrderParameter("elements.date", SortOrder.Descending)
);

(it is to get a full list of articles, then we find out the desired article later. I know I can use Url Slug to retrieve the content, but I need the full list for other stuff)

The issue is that in the JSON response, there is Carousel and PartnerList item, both of them contain the items that I added from the CMS, but individual Carousel items (ImageGridItem) were not presented in the JSON, only Partner items.

Thanks


Solution

  • There could be multiple causes for this behavior. I assume you are using String based rendering of items in Rich text and code first approach so that you should have the ICodeFirstTypeProvider implementation defined and the resolvers as well.

    Possible solutions:

    1. Check that codename is correctly defined in your ICodeFirstTypeProvider implementation pointing to the Partner class.
    2. You could also try to use the DepthParameter to force deeper loading of the data, but it is unlikely to solve the issue since the individual Carousel items are retrieved and they are in the same depth level.

    If any of the assumptions are wrong, let me know. If you are willing to share the implementation of ICodeFirstTypeProvider and the implementations of IInlineContentItemsResolver for all the content types you are loading.

    If you want to debug the SDK right from your project and find the cause on your own, there is a possibility to use the SourceLink.