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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

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 = "test@nousinfo.com";
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.

 

sowmyas_0-1637651139106.png

 

12 REPLIES 12
ozhug
Advocate II
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

TedPattison
Microsoft Employee
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?

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

TedPattison_0-1637770292280.png

 

 

 

Anonymous
Not applicable

I tried with Username, Password and with Access token as well.

But am getting the same error in both cases.

 

 

Anonymous
Not applicable

Am having Premium Per User license. 

Please find the below screenshot for reference.

 

sowmyas_0-1637773616036.png

 

OK, one more thing to check. The Capacity administrator has the ability to set the XMLA endpoint to Off, Read Only or Read Write. If it is set to Off, the behavior you are seeing is expected. Are you able to check the XMLA Endpoint setting in Capacity Settings in the Power BI Admin portal as shown in this screenshot? If you don't have Capacity Admin permissions, you will need to find someonbody who does.  

 

TedPattison_0-1637776466971.png

 

Anonymous
Not applicable

HI @TedPattison 

I have eneabled XMLA Endpoint for ReadWrite and when i try to execute the above code am again getting the same error.

 

sowmyas_0-1637843334351.png

 

sowmyas_1-1637843465109.png

Could you please provide your inputs?

 

I have given you all the ideas I have about what the problem might be and how to troubleshoot it. I cannot think of anything else that might be wrong. I think at this point, you should contact Microsoft support who can captire more diagnositc info that might help to troubleshoot this.

Anonymous
Not applicable

Do capacity settings will be available for premium per user account?

When am checking admin portal capacity settings are not available for my premium per user account.

 

sowmyas_0-1637821865766.png

 

 

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?

 

The documentation doesn't mention anything explicitly but I wouldn't be surprised if there were API limitations too

 

Power BI Premium Per User - Power BI | Microsoft Docs

Anonymous
Not applicable

@lbendlin @TedPattison @Anonymous  Any inputs for the above query?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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