Forums/Community/Zendesk API


HTML in entry body

Trent Korchynski
asked this on January 07, 2011 09:32

Is there a way to submit HTML in the body section of a forum post using the API? Based on this post ( I'm guessing it's not possible - but I was hoping for some confirmation... if it isn't possible, does anyone know of any ways to programmically create forum entries that can have HTML in the body?



User photo
Bob Brown

Yes. An Agent gets a more complete WYSIWYG editor when he is looking at a particular entry. On the editor is a button that says "HTML". This switches to HTML mode I use this a lot to drop in embedded video to the page.


February 03, 2011 12:29
User photo

Post HTML via the API to create a forum entry doesn't work when trying to post code. I've wrapped the HTML code with <pre><code> </code></pre> and Zendesk still renders the HTML. It doesn't work like regular formatting and I'm trying to figure it out. Any thoughts?

November 27, 2011 10:41
User photo
Ken Slattery

I believe the last comment only applies when using Zendesk directly; not when using the API.  I am trying to submit html using the API and can't find a way to do this.  Is there a way to tell the "editor" to go into html mode when using the API?

February 08, 2012 14:13
User photo

The problem isn't with the API, but in the way XML parses data.  It thinks your HTML tags are xml items, and is getting confused.

To fix this, you can wrap all the HTML data inside CDATA tags:  <![CDATA[ *HTML HERE* ]]> when you post it in the request, and this will tell XML to ignore this data as XML and just post it directly as text, then the HTML should be rendered.

Instead of:  <p>Hello</p>

Do:  <![CDATA[<p>Hello</p>]]>

Hope this helps.

April 02, 2012 11:41
User photo
Chirag Desai

Hi Anthony,

Do you know if this would be the problem the other way too? Currently if we pull ticket data over the API, it kills any formatting and pastes the whole text in one long paragraph, including the signature we applied. Is there a way around that which I might be missing?

April 18, 2012 15:03
User photo

My guess is the other way around is a different issue, but I have never tried to pull xml that has html in it from zendesk so I'm not sure if I can be of much help here.  There should be a way you can go to and view the entries you are trying to pull right in the browser.  If it turns out that there is full html code in there, then it must be something going wrong with parsing on your side.  If it is just plain text in there....hmm then maybe zendesk has some weird flag for that or something that has to be set to get full html (the html must be stored somewhere in order for it to render on the page!)

April 18, 2012 15:27
User photo
Chirag Desai

Unfortunately not. The XML does not return any html/breaks or anything so it retrieves it as one paragraph. If you see the screenshot, What's after the --- is auto signature that's added by ZD but is sent over XML as a single line :\

April 18, 2012 22:40
User photo
Steven Yan
Product Manager
Check Answer

Hi everyone, please see our new API documentation, it is possible to post HTML in the body of a forum entry:

Here's an example:

curl \
-H "Content-Type: application/json" -v -u email:password -X POST \
-d '{"topic": {"forum_id": 79161, "title": "My Topic", "body":"<code>This is some code</code>", "topic_type": "articles", "access": "logged in users" }'
April 26, 2012 14:34
User photo

Steven, how abt retrieval? Please refer to screenshot from chiragdesai. Can we get the html content back via api? We are getting it back as one paragraph. 

November 20, 2013 08:09
User photo
James Dietrich

@sales: the body of the topic object (or a topic comment) should contain the HTML in the topic. Here's an example from my Zendesk: (sorry for the original post, the HTML was actually rendered!)

November 20, 2013 08:26
User photo
Chirag Desai


The API does return the HTML text over the API — it did in APIv1 too but it wasn't obvious since the breaks were \n compared to the <br /> but doing a replace fixed that. In APIv2 this is no longer a problem & works both ways, submitting html & markdown is interpreted correctly.


November 20, 2013 08:30