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
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-Json
Here is a script with manual authentication.
SBrown_Murphy
2 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 $PbiCredential
I 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.