Try our conversational search powered by Generative AI!

Ignore Base ContentAPI Model properties from JSON response


I had this posted in different forum earlier but realized this would get more attention here. I am trying to find a way to ignore base properties of Content API Model .

Jun 24, 2020 23:09

Check the documentation below (the CustomContentResultService, to be specific) for instructions on how to remove properties from result:

Jun 30, 2020 9:05

Thank Jorgen, I think the article has some element missing or am not sure if am doing something wrong. I have created class as suggested in article and registered in my initialization module but looks like still the default contentresultservice is executed and not the custom one.

Wondering if anyone has used this can shed some light on it.

Jun 30, 2020 22:57

You can customize the ContentResultService as Jørgen mention above, but please note that it only applies to version 2.6.1 and below. For the latest version of Content Delivery Api, you can implement the 'IContentApiModelFilter' and set the base properties to null:

    [ServiceConfiguration(typeof(IContentApiModelFilter), Lifecycle = ServiceInstanceScope.Singleton)]
    public class CustomContentApiModelFilter : ContentApiModelFilter<ContentApiModel>
        public override void Filter(ContentApiModel contentApiModel, ConverterContext converterContext)
            // Set the properties to null here 

Another way is to use the 'select' parameter in the v3 endpoints to filter out properties: (v3 endpoints still in preview state though).

Jul 01, 2020 3:33

Thanks Le.

This is great. I am using version 2.10. However Filter can set the values to null and the properties will still appear in the response with value as null.

Is there a way to completely hide the properties from the response iteslf?

Jul 01, 2020 17:29

You can use the IncludeNullValues setting in ContentApiOptions. 

context.Services.Configure<ContentApiConfiguration>(c =>
    // if you want to use the v3 endpoints
Jul 02, 2020 7:48


Can't thank you enough. For some reason I couldn't find these steps in documentation and was referring to ContentResultService not knowing it is for version under 2.6.

Is there any preferred place to look for such information?

Jul 02, 2020 20:47
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.