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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Cannot create data source on gateway - PowerBIEntityFrameworkOperationException

I am trying to create a new data source on a gateway using the .NET SDK, but every call results in bad request due to a PowerBIEntityFrameworkOperationException.

 

I've tried to follow the instructions on https://docs.microsoft.com/en-us/power-bi/developer/automation/configure-credentials?tabs=sdk3#confi...

but I may have missed something.

 

string oleConnectionString = "{\"connectionString\":\"provider=SQLOLEDB.1;initial catalog=my database;data source=my server;ApplicationIntent=ReadOnly\"}";
var credentialsEncryptor = new AsymmetricKeyEncryptor(gateway.PublicKey);

var credentials = new BasicCredentials("my username", "my password");
var credentialDetails = new CredentialDetails(credentials, PrivacyLevel.Organizational, EncryptedConnection.Encrypted, credentialsEncryptor);
var oleRequest = new PublishDatasourceToGatewayRequest("OleDb", oleConnectionString, credentialDetails, "New data source");

var newDatasource = await pbi.Gateways.CreateDatasourceAsync(gateway.Id, oleRequest);

 

Things I've tried:

 

1. Creating the data source manually in the Power BI portal. This works.

2. My data source is SQL Server but I need to pass parameters in the connection string so I'm using the OleDB provider. As a test I've tried change the data source type to "SQL" and the connection details to 

"{\"server\":\"my server\",\"database\":\"my database\"}". This results in the same PowerBIEntityFrameworkOperationException exception.
3. I've tried calling the UpdateDatasource method to change the credentials on a manually created data source. This worked, which  suggests that I'm passing the credentials correctly.
1 REPLY 1
jpu
Frequent Visitor

I'm receiving the same error. Also trying it in the sandbox (https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource) returns the same error.

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.