Delivering HTML, markdown or raw text via API


This is an example of how you can call the Scripting API to deliver the body field of a content field in three ways, as HTML, as rendered Markdown and as text stripped of HTML. You can pass it a content id (type:generic content) like this{myId} and it will find the content with the id and return the content.body field as plain text, as HTML and as rendered Markdown.

For more information on what you can do with the Scripting endpoint see the link below:



curl -u -XPOST -H "Content-Type:application/json" -d '{ 
#set($id = $pathParam) 
    #set($id = "f6406747-0220-41fb-86e4-32bce21a8822") 
#set($myContent = $dotcontent.find($id)) 
$dotJSON.put("identifier", $myContent.identifier) 
#set($myBody = $myContent.body) 
$dotJSON.put("bodyHTML", $myBody) 
$dotJSON.put("bodyMarkdown", $markdown.parse($myBody)
$dotJSON.put("bodyStripped", $myBody.replaceAll("<[^>]*>", "")
$dotJSON.put("title", $myContent.title) }'