Rendering Content
Problem
You need to render content. For example, your content utilizes a dataset that has been updated and you want to rerender the content to show the latest information.
Solution
Get the content and render it.
Invoke the render
method to render content.
from posit import connect
= "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
= connect.Client()
client = client.content.get(CONTENT_GUID)
content content.render()
The render
method returns a task
object. This task
tracks the render operation on Connect. You may call wait_for
to await the render operation. A non-zero exit code signals and error during rendering.
= content.render()
task
task.wait_for()assert task.exit_code == 0
Certain content application types support rendering, while others do not. Invoking render
on content that cannot be rendered will result in an error. To avoid this, check the is_rendered
attribute. If content does not support render
, it may support restart.
See Restarting Content.
if content.is_rendered:
content.render()
Invoke the content_render
function to render content.
library(connectapi)
<- "65d02ea5-2e26-436a-afe3-4ef98a8ba8fc"
CONTENT_GUID
<- connect()
client <- content_item(client, CONTENT_GUID)
content <- content_render(content) render_task
Polling the resulting task object will wait until the render has finished, or raise an error if it fails.
> poll_task(render_task)
:
Posit Connect Content Task: 65d02ea5-2e26-436a-afe3-4ef98a8ba8fc
Content GUID: https://connect.example/connect/#/apps/65d02ea5-2e26-436a-afe3-4ef98a8ba8fc/
URL: QK2ks2BsiVv9tPsn Task ID
Certain content application types support rendering, while others do not. Invoking content_render
on content that cannot be rendered will result in an error. To avoid this, check the content$is_rendered
attribute. If content does not support content_render
, it may support content_restart.
See Restarting Content.
if (content$is_rendered) {
content_render(content)
}