Forum Discussion
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
- AnonymousNot applicable
lbendlin TedPattison Anonymous Any inputs for the above query?
- TedPattisonMicrosoft Employee
As far as I can tell, the connection string looks fine. Can you confirm that this workspace is associated with a dedicated capacity?
- AnonymousNot 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?
- lbendlinSuper User
The documentation doesn't mention anything explicitly but I wouldn't be surprised if there were API limitations too
- TedPattisonMicrosoft 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- AnonymousNot applicable
Am having Premium Per User license.
Please find the below screenshot for reference.
- ozhugAdvocate 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