HTML in entry body

Answered

Comments

11 comments

  • Avatar
    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.

     

  • Avatar
    Benni

    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?

  • Avatar
    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?

  • Avatar
    Anthony

    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.

  • Avatar
    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?

  • Avatar
    Anthony

    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 zendeskaccount.zendesk.com/entries.xml 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!)

  • Avatar
    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 :\

  • Avatar
    Steven Yan

    Hi everyone, please see our new API documentation, it is possible to post HTML in the body of a forum entry: http://developer.zendesk.com.

    Here's an example:

    curl https://yoursubdomain.zendesk.com/api/v2/topics.json \
    -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" }'

  • Avatar
    sales

    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. 

  • Avatar
    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: https://gist.github.com/jbdietrich/7566276 (sorry for the original post, the HTML was actually rendered!)

  • Avatar
    Chirag Desai

    @sales,

    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.

    Cd

Please sign in to leave a comment.

Powered by Zendesk