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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
BenDuke
Frequent Visitor

Uploading to Power BI Embedded with the C# Client with a File Source and Direct Query Source Fails

I'm using Microsoft.PowerBI.Api 4.18 in C#

 

We allow clients to build their own PBIX files in Desktop and upload to our portal.

 

The general upload method is

1. Import File

2. Take Ownership of Datasets

3. Update credentials for SQL Server Connections

 

Some of the PBIX files contains multi data sources. It works fine when

* I have a file and a SQL Import

* I have a DirectQuery and a SQL Import

It does not work when

* I have a file and a Direct Query

 

Using the client.Datasets.GetDatasources(_groupId, dataset.Id).Value API I can see that in a working scenario it looks like

BenDuke_0-1709096072569.png

however in my failed scenario I get no datasourceId or gatewayId

BenDuke_1-1709096108172.png

 

Looking at the Direct Query in the Semantic Model I get the following error

BenDuke_3-1709096251122.png

 

 

I have no idea whats going wrong as my searches have been yielded nothing.

 

Any help please?

 

 

 

3 REPLIES 3
BenDuke
Frequent Visitor

I've continued to test with other permuations and no matter what I do, once I include a File Data Source with a Direct Query the direct query will fail with the below message.

BenDuke_0-1709608326683.png

It appears that the Direct Query will fail due to a gateway error associated witht the file.

lbendlin
Super User
Super User

You should not allow file data sources on a user's computer.  It requires a gateway, worst case a gateway on that same computer - on every one of them.

 

Only accept files stored on OneDrive.  Those do not require gateways as long as you don't attempt to merge queries with other on-prem data sources.

Thank you for your response.

 

The goal here is not to allow ongoing accesss to the file, it become static data is works fine by itself. It can't be refreshed from our service and that is well understand and accepted by the client and us.

 

The problem is that when a file and a Direct Query are in the PBIX the Direct Query gets broken in the import.

This does not occur if I mix a file with a SQL Import or a SQL Import with a Direct Query.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.