Recent searches
No recent searches
Creating a ticket with markdown in comment auto-generates an html_body
Posted Aug 08, 2023
I am attempting to create a ticket using the `comment.body` field to use Markdown formatting documented here: https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/#bodies
Here's an example curl request with my test body:
curl https://{subdomain}.zendesk.com/api/v2/tickets.json \
-d '{"ticket": {"assignee_id": 1234, "id": null, "subject": "A test email", "comment": {"body": "This message should render **markdown**"}, "requester": {"email": "redacted@rdctd.io", "id": null, "name": "redacted"}}}' \
-v -u "{username}:{password}" -X POST -H "Content-Type: application/json"
The sent email is not formatted as expected. My suspicion is that the body is incorrectly translated to HTML because `html_body` is populated in the response:
...ticket audit response
"events":[{"id":12345,"type":"Comment","author_id":15379865986587,"body":"This message should render **markdown**","html_body":"<div class=\"zd-comment\" dir=\"auto\"><p dir=\"auto\">This message should render **markdown**</p></div>","plain_body":"This message should render **markdown**","public":true,"attachments":[],"audit_id":12345}
...
Is there something wrong with my request? I am following the documentation by only including one of `body` or `html_body`. Is the documentation wrong? Or is there an API bug?
2
6
6 comments
Dwight Bussman
HeyO Eric - I'm seeing the same behavior in my test account, and it seems to disagree with the documentation. I'm raising this matter to our developers to see if this was an intentional change or something they'd be able to fix.
0
Dwight Bussman
I suspect this is an unintentional change, as updating a ticket with a similar payload
bottom comment is "create" / top comment is "update":
0
Dwight Bussman
Wait a sec..... I think I figured out what's going on here....
Markdown formatting is only available for comments made by Agents/Admins
Although your API request is authenticated by an agent, the comment will only render that markdown if the author of the comment is an agent/admin.
Please let me know if this helps to explain what you're seeing. If you'd like to discuss this further, please feel free to contact our support team
0
Dwight Bussman
I'm going to reach out to our documentation team to see that our docs for the Ticket Comments API do a better job of clarifying this.
Thanks for bringing this to our attention!
0
ERIC
Thanks for the explanation!
The comment now renders markdown when submitter_id is part of the request body:
In my testing, I am authenticating as an agent and the comment was correctly attributed to the authenticated agent. It seems that the API requires the submitter_id be set in order to render a markdown comment.
0
Dwight Bussman
The same holds true when passing the author_id (in the ticket-comment instead of the ticket object)
1