Why are my IContent properties returned inside of "properties" property?

Vote:
 

Hi all,

I am currently working on creating a custom endpoint which would return a a list of IContentApiModel. Now I was able to convert my content to a IContentApiModel using the following statement:

var productContentApiModel = contentConvertingService.Convert(currentVariantProduct,
    new ConverterContext(currentVariantProduct.ContentLink, language, contentApiOptions, ContextMode.Default, null, null, false));



Now When I returned the productContentApiModel from the api I noticed that the properties for the content are returned inside of a property called "properties". This is different from the response coming back from the content delivery api where the properties are flattend into the object itself and not inside the "properties" property. What changes do I need to have my properties returned outside of the "properties" property? Is there a step I'm missing in my code above?

Please note the contentApiOptions are injected into my service and it's the same options used by the content delivery api.

Any help is appreciated.

#330168
Edited, Sep 18, 2024 10:31
Vote:
 

I believe you can use the expand property of ConverterContext to control it, something like

new ConverterContext(currentVariantProduct.ContentLink, language, contentApiOptions, ContextMode.Default, null, "*", false));

expand = "*" means expand all. otherwise it's matching property names (I think)

#330223
Sep 19, 2024 12:21
Vote:
 

It's actually FlattenPropertyModel that controls this:

new ConverterContext(
    currentVariantProduct.ContentLink,
    language,
    new ContentApiOptions
    {
        FlattenPropertyModel = true
    },
    ContextMode.Default,
    null,
    null,
    false);
#330230
Sep 19, 2024 17:18
* 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.