Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

assign group to capacity via SDK returns unauthorized

I am implementing a provisioning tool using the PowerBI.CSharp.SDK, authenticating to PowerBI using a service principal.

The code is based on the AppOwnsData code sample for authentication.

 

I can successfully create a new workspace, import a PBIX, and modify the datasource and credentials to point to a specific Azure SQL database.

 

I need to assign the new workspace to a PowerBI Embedded capacity. I can do this in the powerbi portal, but my code returns "unauthorized" despite the service principal having:

  • admin rights to the workspace
  • added as capacity admin
  • assigned Tenant.Read.All & Tenant.ReadWrite.All API permissions
  • Given the Power BI Administrators role in Azure AD

The code looks like this, and I have verified that the workspace id and capacity id are valid.

Fails on the last line with Unauthorised response from the REST API.

Can anyone spot what am I doing wrong?

 

 

1 Reply

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

     

    It seems there is something wrong with authorization from the rest api. I can't reproduce your scenario, I'd like to suggest you open a support ticket here if you have a pro license for further help.

     

    Best Regards
    Allan