I'm trying to use this API call: https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-add-user-as-admin.
I'm authenticating with a Service Principal which has tenant.ReadWrite.All and Fabric Administrator role (previously Power BI Service Administrator).
With the token generated with the Service Principal, I'm able to run other Admin APIs like https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-get-group-as-admin.
However, when running Add user as admin, I'm getting 401 unauthorized.
I'm runnning it with Python
group_id = '<workspace_id>'aad_group_object_id = '<servicePrincipal_cliend_id>'new_permission = 'Contributor'url = f'https://api.powerbi.com/v1.0/myorg/admin/groups/{group_id}/users'headers = {'Authorization': f'Bearer {token}','Content-Type': 'application/json'}data = {'principalType': 'App','identifier': aad_group_object_id,'groupUserAccessRight': new_permission}response = requests.post(url, headers=headers, json=data)
I cannot see how there's an authorization issue, any ideas?