Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
odumna
Helper I
Helper I

Is there posibility to call power admin api using sql queries ?

Hi

Is there posibility to call power admin api using sql queries?
For example, I need to get list of my organizational workspaces and save this information into some table on sql server database.


4 REPLIES 4
lbendlin
Super User
Super User

Run the API call in Powershell and push the resultset into a SQL Server database table.

is there some documentation about using cmdlets for powershell ?
what protocols it is used, what path and ports should be opened for requests?  
In my case, server (where my sqldatabase exists) doesn't have access to internet, so I need to ask my network team-members to open access to powerbi site.... or smth like this... 
 

These are standard Powershell functions.  Nothing but HTTPS.

 

Something along these lines

 

$dataset = "9941f7c0-xxxx-4382-959c-731a752e9a8f"

$URI = "https://api.powerbi.com/v1.0/myorg/datasets/$dataset/executeQueries"

$query = '

EVALUATE
<your DAX here>      
'
$body = '{ queries:  [ { query : "' + $query.Replace('"','\"') + '" } ],"serializersettings":{ "includeNulls":true} }'
$res = Invoke-RestMethod -Headers $authHeader -Uri $URI -Body $body -Method POST
$rows = $res.Substring(3) | ConvertFrom-Json | Select-Object -Expand results  | Select-Object -Expand tables  | Select-Object -Expand rows
,$rows | Write-SqlTableData -ServerInstance "server" -DatabaseName "database" -SchemaName "dbo" -TableName "table" 

Thank you for answer. I will try to do it. Let you know if I have additional queations.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors