November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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).
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?
You can use the IncludeNullValues setting in ContentApiOptions.
context.Services.Configure<ContentApiConfiguration>(c =>
{
c.Default(RestVersion.Version_2_0)
.SetIncludeNullValues(false);
// if you want to use the v3 endpoints
c.Default(RestVersion.Version_3_0)
.SetIncludeNullValues(false);
});
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 .