Blocks in XHtmlString and content delivery api

Vote:
 

Hello,

We have blocks within XHtmlString but they are removed when calling content delivery api.. 

I read that using a block having a corresponding view will work.. 

But we dont have any controllers and views, we have a headless solution. 

What is the right way to implement support for blocks in XHtmlString in the Content delivery Api response? 

#247260
Jan 19, 2021 13:55
Vote:
 

It should work by default.
Do you have any Custom Property Model Converters (search for XHtmlPropertyModel in your code)? Or extending serialization of content?
Which version of API are you using?

#247273
Jan 19, 2021 14:56
Vote:
 

We use the 2.17.0 and no Custom Property Converters.. no extension of serialization.. 

The blocks are just getting stripped off while all the other content goes through in the XHtmlString when making a call to the api.. 

Bit confusing why it gets stripped away :(, guess is how it works, but find no documentation around this


#247275
Jan 19, 2021 15:03
Vote:
 

By default it should give you something like
"mainBody": {
        "value": "<p>Your data</p>",
        "propertyDataType": "PropertyXhtmlString"
    }

#247277
Jan 19, 2021 15:10
Vote:
 

Can you drop the definition of your property here?

#247278
Jan 19, 2021 15:16
Vote:
 

well it does.. except the blocks are missing in the "Value" 

        [CultureSpecific]
        [Display(
            Name = "Hero introduction text",
            Description = "Introduction text for the hero",
            GroupName = TabNames.Hero, Order = 25)]
        public virtual XhtmlString HeroIntroHeading { get; set; }

So nothing special.. but i guess something is happening while serializing the content.. 

#247281
Jan 19, 2021 15:51
Vote:
 

Yes, next step do you have any Modle Converter?

#247282
Jan 19, 2021 16:31
Vote:
 

no, no model converters.. i tried the example alloy test site and it works kind of out of the box.
so the issue is totally on our end :/. Thought i missed something obvious but the error is probably somewhere in our code somewhere.. 

Will keep this thread updated when i find what we have missed.. but i realise that its kind of hard to get help from someone without showing the code itself

Well is someone have some tip or pinpoints in right directions, they all are welcome :)! 

#247315
Jan 20, 2021 8:44
K Khan - Jan 20, 2021 10:47
I will be checking all the ends that can affect serialization or output.

Serialization
- any model converters
- any ContentResultService

Effects on generated JSON
- any other external factors (proxy/policies) that might refuse JSON like some security policy (e.g. Azure APIM)
* 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.