Forum Discussion
C# XMLA TOM Connection Failing
- 9 months ago
v-sgandrathi GilbertQ I appreciate the back and forth you've provided. I have been unable to get the Tabular Object Model to work. However, I have found a way using the ADOMD connection to get the datasource names that includes the actual table or view named used in each Power BI report and this helps.
Again thank you for your time. I may revisit this as I'd like to figure out how to get TOM to work. I'm not sure if it's my .Net Framework, if it needs Core or something else.
Hi TCavins
The valid way to connect to a Power BI semantic model using the Tabular Object Model (TOM) is through the XMLA endpoint of a Premium or PPU workspace. You can authenticate either using a service principal or an Azure AD token obtained via MSAL. The connection must reference your tenant ID in the XMLA URL rather than myorg, and the service principal must be granted the necessary permissions within both Azure AD and the Power BI workspace.
Refer the Microsoft’s official documentations:
Semantic model connectivity and management with the XMLA endpoint in Power BI - Microsoft Fabric | Microsoft Learn
Programming Power BI semantic models with the Tabular Object Model (TOM) | Microsoft Learn
Thank you.
- TCavins10 months ago
Helper V
v-sgandrathi Thank you for your reply.
I've seen those links you shared and have attemped both of the following:
string workspaceConnection = "powerbi://api.powerbi.com/v1.0/myorg/YOUR_WORKSPACE"; string tenantId = "YOUR_TENANT_ID"; string appId = "YOUR_APP_ID"; string appSecret = "YOUR_APP_SECRET"; string connectStringApp = $"DataSource={workspaceConnection};User ID=app:{appId}@{tenantId};Password={appSecret};"; server.Connect(connectStringApp);string workspaceConnection = "powerbi://api.powerbi.com/v1.0/myorg/YOUR_WORKSPACE"; string userId = "YOUR_USER_NAME"; string password = "YOUR_USER_PASSWORD"; string connectStringUser = $"DataSource={workspaceConnection};User ID={userId};Password={password};"; server.Connect(connectStringUser);Even when I replace myorg with my domain, I get the error: FormatException: Input string was not in a correct format.
I can connect via SSMS using myorg and not the domain name but I have the need to use code and loop through all the databases rather than manually clicking each one in SSMS.