1 Reply Latest reply on Apr 4, 2017 1:18 PM by gbrettmiller

    Invalid HTML in content text field


      Hi All,


      create discussion via REST API (/api/core/v3/contents) throws error recently like below, before it was working fine.


      { "error":{ "message": "Invalid HTML in content text field","status": 400,"code": "contentBodyInvalid" } }


      When I analyze the root cause of this issue I found that character '&' is making the problem. I don't know why the API accepts Subject field having '&' but not content.



      "subject":"[1234567] - [abc & xyz Inc.] - [[abc] abcdefghjk]"



      Migration KX(~!@#$%^*)



      Migration KX(~!@#$%^&*)







           "subject":"[1234567] - [abc & xyz Inc.] - [[abc] abcdefghjk]",




                          ID #: <a href=\"https:\/\/abc.com\/case?id=1234567\">1234567<\/a><br>

                          Product1: abc<br>

                          Product2: xys<br>

                          <strong>Question 1?:<\/strong> <br>Migration KX(~!@#$%^&*)<br>

                          <strong>Question 2?:<\/strong> <br>Migration KX<br>





      Can you guys please give some suggestion to fix this.




        • Re: Invalid HTML in content text field

          We've run into this problem as well. I think the difference is that the Subject field does not allow / process any type of markup, so it reads the string as-is whereas the Content field will process the contents as html and so will read special characters as those characters and not just a piece of text.  One option that I've used in the past is to use a regular expression to replace the "&" with "and" before posting:


          contentText = String(contentText).replace(/[&]/g, "and");

          1 person found this helpful