Forum Discussion
Refresh power bi report from SSIS
Hello , Would you mind to share how to use this script? Step by step in SSIS ?
Hi kucluk_ok
EDIT: Before this works. You must have a refresh plan on the report.
I don't have one at hand. I switched to using a 'Windows Tasks' calling the PowerShell script below.
See this guide How to Schedule PowerShell Script Using Task Scheduler (o365reports.com)
But it could also be a SSIS job (search after PowerShell script in SSIS) or SQL agent job.
PowerShell script:
$path_array =
"report_path1",
"report_path2",
...
"report_pathx"
foreach ($path in $path_array)
{
$uri = "[InsertURL]/reports/api/v2.0/PowerBIReports(path='" + $path + "')/CacheRefreshPlans"
$refreshplan = Invoke-RestMethod -UseDefaultCredentials <# -Credential $creds #> -uri $uri
try {
$refreshuri = "[InsertURL]/reports/api/v2.0/CacheRefreshPlans(" + $refreshplan.value.Id + ")/Model.Execute"
}
catch {$error[0]}
Invoke-RestMethod -UseDefaultCredentials <# -Credential $creds #> -method POST -uri $refreshuri -verbose
}
Hope it helps. Regards Taico