Viewing embedded content in Telligent Community REST API responses

This is part of a set of "snippet" posts that I'm going to try and write more often, these posts are (hopefully) useful code snippets I keep forgetting about, so blogging here for easy reference later.

When you get Telligent Community content via the REST API, by default embedded content (such as Videos or Audio), isn't returned, instead it is replaced with a message like:

(Please visit the site to view this video)

If you would like to view the full content you can by setting the PostTarget parameter to Web when calling the API, for example:

https://www.your-site.com/api.ashx/v2/blogs/1/posts/1.json?PostTarget=Web

This will return the code to render your video, audio (or any other file viewer content) as part of the response so the content will render the same way as it would on your Telligent site.


Note

I had an issue when doing this that YouTube videos were stopping the rest of the page loading when using this method. It appears this is due to the iframe tag that is returned being self closing, rather than a separate closing tag, which causes invalid HTML. I'm currently solving this by running the post content through a Regex before display that changes to valid HTML:

  • Post