Text elements containing HTML show up in the Kentico Cloud UI formatted when imported by the CM API

adamadam Member ✭✭
edited December 2017 in Back-end Development


I noticed a strange side effect with the CM API (I know it's still Beta, just wanted to report the issue). We have a content type called "raw_html" to deal with some pages that we haven't yet migrated to our new content structure. The content type just contains a single text element. After uploading them via the CM API, when viewing them via the Kentico Cloud UI, the formatting is shown in the text field instead of the raw string. The expected contents are returned when viewing the item via the preview API, so it only seems to affect the UI. To test if this was an issue with all content items, I manually created one via the UI, with the same string, and the formatting is never shown in the UI (just the raw html as expected).

Here is a sample string '<p style="text-align: center;"><i>We also call this "Workers' Compensation."</i></p>\n'

I won't post my preview api key here, but if you want to see an example:
projectid: 0542d611-b6d8-4320-a4f4-35ac5cbf43a6
codename of imported item: _l_alabama_business_insurance_text_1342084647
codename of manually entered item: test_adam



  • JanS2@kentico.com[email protected] Member, Kentico Staff mod

    Thank you for reporting this Adam, we'll look into it and let you know.

  • JanS2@kentico.com[email protected] Member, Kentico Staff mod
    edited December 2017

    From what I was able to find out you need to actually encode the text value before PUTting it, with that I was able to get the raw value to the text field. I PUT your string like this:

      "elements": {
        "cmapi_text_field": "&lt;p style=\"text-align: center;\"&gt;&lt;i&gt;We also call this \"Workers' Compensation.\"&lt;\/i&gt;&lt;\/p&gt;\\n"

    But then I get the encoded value from Deliver API, so it's not behaving consistently. I will report this as a bug and keep you updated about the progress. Thanks again for lettting us know!

  • Thanks @JanSedo !

  • JanS2@kentico.com[email protected] Member, Kentico Staff mod

    Hey Adam, our devs released a fix for this just now, so it should behave as expected.

  • adamadam Member ✭✭

    Was able to test and verify this tonight. Looks good now!

Sign In or Register to comment.