Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Programatically connecting to power BI premium workspace using workspace url

Am trying to connect to a Power BI workspace by using the Workspace Connection URL.

Below is the code:

public static void ConnectToPowerBIAsUser()
{
string workspaceConnection = "powerbi://api.powerbi.com/v1.0/myorg/Superstoresales";
string userId = "[email protected]";
string password = "********";
string connectStringUser = $"DataSource={workspaceConnection};User ID={userId};Password={password};";
server.Connect(connectStringUser);
}

When i execute the code am getting the below error:

 

Microsoft.AnalysisServices.ConnectionException: 'The connection string is not valid.'

Inner Exception:

FormatException: Input string was not in a correct format.

 

 

12 Replies

  • TedPattison's avatar
    TedPattison
    Microsoft Employee

    As far as I can tell, the connection string looks fine. Can you confirm that this workspace is associated with a dedicated capacity?

    • Anonymous's avatar
      Anonymous
      Not applicable

      TedPattison No workspace is not associated with dedicated capaticy. 

      Premium per user is enabled for the  workspace.

      Do we require premium capacity to perform data refresh?

       

    • TedPattison's avatar
      TedPattison
      Microsoft Employee

      Can you confirm your user ID is for a user with a Power BI Premium per User license. 


      Did you copy the URL from workspace setting to ensure it matches

       

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Am having Premium Per User license. 

        Please find the below screenshot for reference.

         

         

  • ozhug's avatar
    ozhug
    Advocate II

    The key here is using the correct libraries

    counter-intuitively do not use the Microsoft.AnalysisServices.Tabular library 
    you need to use these libraries based on your code base.
    For .NET Core we need to install those two libraries:

    Microsoft.AnalysisServices.NetCore.retail.amd64

    Microsoft.AnalysisServices.AdomdClient.NetCore.retail.amd64 

    For .NET Framework those two libraries:

    Microsoft.AnalysisServices.retail.amd64

    Microsoft.AnalysisServices.AdomdClient.retail.amd64