Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Try setting this way, I think content delivery uses its own settings.
services.ConfigureContentDeliveryApiSerializer(settings =>
{
settings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
Interesting. Did not know about that configuration option - the content delivery api response is however is correct.
This is a custom api controller. - The answer after a long search was this.
Use the DefaultContractResolver, with a CamelCaseNamingStrategy and all ctor parameters to 'true'.
We have a weird issue with formatting of ContentApiModel to JSON.
// Startup.cs services.UseNewtonsoftSerialization(assembly, settings => { settings.Converters.Add(new StringEnumConverter(new DefaultNamingStrategy())); settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); settings.StringEscapeHandling = StringEscapeHandling.EscapeHtml; settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); ... services.AddCms(); ...
// api controller, _contentApiOptions is injected in constructor [HttpGet] [Route("{contentLinkId:int?}")] public IActionResult GetAll([FromRoute] int? contentLinkId = null) { var content = new List<ContentApiModel>(); var language = LanguageSelector.AutoDetect(true).Language; foreach (var page in GetAllResellers(contentLinkId)) { var model = _contentConverter.Convert(page, new ConverterContext(page.ContentLink, language, _contentApiOptions, ContextMode.Default, null, "*", false)); content.Add(model); } return new JsonFormattedResult(content); }
Resulting JSON, some properties are propper CamelCase - some are not.

Any ideas?