The Civis API supports Tableau workbook extract refreshes, ensuring that your reports are always backed by the most up-to-date data.
Refreshes can be triggered with the post_refresh endpoint in the Python and R clients, which you can access from Python or R scripts in Platform. This will also allow you to schedule your script or include it as a task in a workflow. For example, you might have a workflow that ingests and transforms data that is ultimately fed to a report -- you can add an API refresh at the end of this workflow to ensure the report gets updated as the data does. It is not currently possible to track when a refresh has completed.
Triggering an extract refresh via the API only requires the ID of the report in Platform (note that this ID is different from the workbook ID in Tableau Server). You must have editor permission on the report object in order to trigger an extract refresh. Examples using both the Python and R API Clients are shown below. General API documentation is here.
import civis
client = civis.APIClient()
report_refresh = client.reports.post_refresh(53104) #provide the id of the report
print(report_refresh)
To refresh multiple reports, use:
import civis
client = civis.APIClient()
#use a loop to refresh multiple reports
id_list = [53104, 98765, 34567]
for id in id_list:
refresh = client.reports.post_refresh(id)
print(refresh)
In the R client, you can use the following:
library (civis)
report_refresh <- reports_post_refresh(53104)
For multiple reports, use:
library (civis)
id_list <- c(53104, 98765, 34567)
for (id in id_list) {
refresh <- reports_post_refresh(id)
print(refresh)
}
Comments
0 comments
Article is closed for comments.