Forum Discussion
Automate Dataset Refresh with PowerShell Scripts
Thanks for response lbendlin , ducky Actually, i came to know that we have some permissions issues.
APP is not enabled with API permissions to invoke script currently.
Kindly pls help me with what permissions should i be requesting for it at APP end & PBI service side. (I'm not Admin)
I have couple of Dataflows and Datasets which are exist in workspace i would be required to automate them with Powershell.
The Source is snowflake and i need to integrate PBI with UC4, where the actual Data jobs are running/monitoring. As soon as the job get completes in UC4, i should be connecting thru Powershell scripts and refresh related Datasets in PBI service. - Does anyone have implemented this scenario ?
Do we have any connector to check with UC4 jobs completetion status and inovoke powershell scripts. I really appreciate if we have any scripts/documentation to refer it.
Thanks,
- Anonymous2 years agoNot applicable
Hi raghav20 ,
You are refreshing the Power BI dataset by invoking the REST API through the service principal.
The service principal needs to be added with the Dataset.ReadWrite.All API permission.
Then, the /Service principals can use Fabric APIs/ feature needs to be enabled in the admin portal.
Finally, as this superuser lbendlin said, the notifyOption body may needs to be specified when using POST.
Datasets - Refresh Dataset In Group - REST API (Power BI Power BI REST APIs) | Microsoft LearnBest Regards,
Dengliang Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- raghav201 year agoFrequent Visitor
Hi Anonymous , Thanks for the response after i have received appropriate permissions from App, I was able run the scripts and Dataset refresh is happening for few reports.
I have some challenge here, i was unable to refresh couple of Datasets. These datasets were connected with another semantic model as Direct Query. Connection flow as below
Source -> Dataflow ->Semantic Model 1 (Import mode) ->Semantic Model 2 (Direct Query)->ReportSemantic Model1 is a Just model it has custom fields and actual columns from the source
Semantic Model 2 -- Report All visuals are avilable here.
In order to see the latest Data in Report i need to refersh Semantic Model 1 & Semantic Model 2.
I was able to refresh Semantic Model 1 without any issues but, when i try to refersh Semantic Model 2 with same PowerShell script, i am getting below error.
C:\Data\Files\PShell\Refresh_Dataset.ps1 : Failed to initiate dataset refresh: The remote server returned an
error: (415) Unsupported Media Type..Exception.Message
At line:1 char:1
+ .\Refresh_Dataset.ps1 -workspace POC -dataset Report_Model
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Refresh_Dataset.ps1Response Body: {"error":{"code":"InvalidRequest","message":"Invalid dataset. This API
can only be called on a Model-based dataset"}}
How can i make my script to work for other Dataset as well, is there any way to make it work ? Thanks in advance!- lbendlin1 year ago
Super User
You are only allowed to request refreshes for semantic models that you own.