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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors