Forum Discussion
Anonymous
4 years agoNot applicable
Push dataset to power bi premium workspace using xmla endpoints
I need to read dataset (.json file) from a specified location (c:\testing\datset.json) and push the dataset to Power BI premium workspace. How to programatically read the json file content and pus...
lbendlin
Super User
4 years ago"push the dataset to power bi workspace using XMLA endpoints"
That's not how push datasets work (yet). You need to use the push URL and put your data payload into the POST body. Here's an example with Powershell. Replace the body construct with the contents of your JSON file.
#capture stats
$date = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:00.000Z')
$mem = (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue
$proc = (Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue
$disk = (Get-Counter '\LogicalDisk(C:)\% free space').CounterSamples.CookedValue
$svg = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><text font-size='12px' font-family='sans-serif' transform='translate(12, 75) rotate(270)'>" + $env:computername + "</text></svg>"
#enforce TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$payload = @{
"Host" = $env:computername
"Timestamp" = $date
"Available Memory in MB" = $mem
"Processor Load %" = $proc
"% Free on C:" = $disk
"img" = $svg
}
#push URL
$endpoint = "https://api.powerbi.com/beta/<tenant>/datasets/<dataset>/rows?key=<push key>"
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body $payload