Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
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.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.