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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ducky
Advocate I
Advocate I

API - UpdateGroupAsAdmin - Assign a log analytics workspace

Im trying to assign to each Powerbi workspace a log analytics workspace via API. Below its part of my script that should do that. 
Only showing this as the rest Im sure its working. I believe that something is amiss with the request body. But this is how its constructed in the docs so i have no idea why its not working. 
 (im not using the profile id as its not in the documentation, although I tried with it too) 

 

$workspaceId 
 $profileId 

# Construct the headers and URL for the API call
$SPHeader = @{'X-PowerBI-profile-id' = $profileId}
$url = "https://api.powerbi.com/v1.0/myorg/admin/groups/$workspaceId"

$body = @{
      "logAnalyticsWorkspace" = @{
        "subscriptionId" = "subscriptionId"
        "resourceGroup" = "resourceGroupName"
        "resourceName" = "LogAnalyticsWorkspaceName"
      }
    }

    # Make the API call
    $response = Invoke-PowerBIRestMethod -Method 'Patch' -Url $url -Body $body -Verbose
    $response | ConvertTo-Json

 

1 REPLY 1
lbendlin
Super User
Super User

When you Invoke-PowerBIRestMethod you use relative URIs, not the full URL  (you would use the full URL with Invoke-RestMethod)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.