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 .
Check the documentation below (the CustomContentResultService, to be specific) for instructions on how to remove properties from result:
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.
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: https://world.episerver.com/documentation/class-libraries/rest-apis/content-delivery-api/#/ContentApi/ContentApi_GetContent (v3 endpoints still in preview state though).
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?
You can use the IncludeNullValues setting in ContentApiOptions.
// if you want to use the v3 endpoints
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?