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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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