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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
rshahrabani
Frequent Visitor

PowerBIClient.Gateways.GetGateway returns Unauthorized error

Trying to configure datasource credentials at runtime and the call to PowerBIClient.Gateways.GetGateway returns Unauthorized error.  Below is the snippet of code used to do this:

 

Dim basicCredentials As BasicCredentials = New BasicCredentials(username, password)
Dim gateway As Gateway = powerBIClient.Gateways.GetGateway(datasource.GatewayId)

Dim credentialsEncryptor = New AsymmetricKeyEncryptor(gateway.PublicKey)
Dim credentialDetails = New CredentialDetails(basicCredentials, PrivacyLevel.Private, EncryptedConnection.Encrypted, credentialsEncryptor)
Dim udsRequest As UpdateDatasourceRequest = New UpdateDatasourceRequest(credentialDetails)
powerBIClient.Gateways.UpdateDatasource(datasource.GatewayId, datasource.DatasourceId, udsRequest)

 

The above code was found in the link:

https://docs.microsoft.com/en-us/power-bi/developer/automation/configure-credentials?tabs=sdk3

 

Any help would be appreciated.

Thanks.

0 REPLIES 0

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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