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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.