Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I'm trying to do some basIc scripting to regularly pull my PBI refresh history as part of a bigger set of usage metric tracking, using Azure function apps. All my functions log in to PBI with a service principal that has delegated Tenant.ReadWriteAll permissions, like so:
$applicationId = "bbd694ab-1da9-426f-97ab-896661bc32a7"
$securePassword = "[redacted]" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "93fb7985-8893-49e5-8440-bb350d28a54f"
This works fine for most things, including most API URLs for Invoke-PowerBIRestMethod, but when I try to use Invoke... with the Get Refresh History In Group call I get a 404 error. This *only* happens when I'm accessing the API as the service principal; if I make the API call in Postman using an Authorization header it works fine. My query is
$url = "https://api.powerbi.com/v1.0/myorg/groups/f1f6f5db-02b3-4650-a4aa-fc93171aede9/datasets/173489c2-285c-484d-ac0d-7e382eec87ce/refreshes"
invoke-powerbirestmethod -Url $url -method Get
I get 404s like this on every non-admin API call; the admin versions all work fine.
I'm pretty new to working with Powershell and the world of Azure so this is probably something pretty obvious, but it's eating my lunch.
Solved! Go to Solution.
Hi @Anonymous ,
I have check Power BI REST API offical blog and I think Get Refresh History In Group API should support Service Principal.
If 404 error only appears when you choose Service Principal for authentication, please check whether you configure Service Principal correctly. You should give security group which has added Service Principal as a member the API permission from Admin portal in Power BI Service and add Service Principal as a member in Power BI Workspace.
For reference: Embed Power BI content with service principal and an application secret
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
I have check Power BI REST API offical blog and I think Get Refresh History In Group API should support Service Principal.
If 404 error only appears when you choose Service Principal for authentication, please check whether you configure Service Principal correctly. You should give security group which has added Service Principal as a member the API permission from Admin portal in Power BI Service and add Service Principal as a member in Power BI Workspace.
For reference: Embed Power BI content with service principal and an application secret
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 |
User | Count |
---|---|
10 | |
7 | |
5 | |
4 | |
4 |