Forum Discussion
SBrown_Murphy
2 years agoFrequent Visitor
Looking for the Power BI API for MQuery
When administering a Power BI enviorment were the reports source their data from on-prem SQL databases I've found it is hard match a problem SQL query I see in the database with the symantic model th...
- 2 years ago
How do you plan to authenticate? Did you register an app in AD with the required scope?
$requestBody = @" { "queries": [{ "query": "EVALUATE TOPN(10,Dates,[Date])"}] ,"serializerSettings":{"includeNulls":true} } "@ Login-PowerBI $requestUrl = "datasets/xxx/executeQueries" $result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Body $requestBody $parsed = $result | ConvertFrom-JsonHere is a script with manual authentication.
lbendlin
2 years agoSuper User
- SBrown_Murphy2 years agoFrequent VisitorThank you for this suggestion but this is not working for me either. It looks like there is a function that is supposed to return the DAX Query but it errors out too. 'https://api.powerbi.com/v1.0/myorg/datasets/{dataset_ID}/executeQueries' (400): Bad Request I tried calling that API URL from the PowerShell script and got the same error. What I'm really looking for is an API URL that will work so it can be added to my PowerShell scripts.
- lbendlin2 years agoSuper User
How do you plan to authenticate? Did you register an app in AD with the required scope?
$requestBody = @" { "queries": [{ "query": "EVALUATE TOPN(10,Dates,[Date])"}] ,"serializerSettings":{"includeNulls":true} } "@ Login-PowerBI $requestUrl = "datasets/xxx/executeQueries" $result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Body $requestBody $parsed = $result | ConvertFrom-JsonHere is a script with manual authentication.
- SBrown_Murphy2 years agoFrequent Visitor
In the scripts I've written up to this point I've used this to connect.
Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId -Credential $PbiCredentialI have a service pricible that has Admin rights (the same as I have). This makes it easy to automate the script to run from the SQL server were the data is loaded.