cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
timlin
Frequent Visitor

Programmatically enter missing dataset credentials using API

Hi,

 

I am leveraging the REST API's to invoke a Dataset Takeover and Update Parameters method, however as the new owner is different to the original/publishing owner the dataset requires updated credentials before it can be refreshed. Currently I have to manually enter the missing credentials to enable a refresh.

 

Data source error:It looks like scheduled refresh failed because at least one data source is missing credentials. To start the refresh again, go to this dataset's settings page and enter credentials for all data sources.
Cluster URI:WABI-NORTH-EUROPE-redirect.analysis.windows.net
Activity ID:00000000-0000-0000-0000-000000000000
Request ID:e9498bc8-a818-4d27-9b35-06a4b0e94582
Time:2019-12-17 13:58:44Z

 

My objective is to programatically script all these steps avoiding manual steps. The dataset does not use any gateways and only contains a single Azure SQL Database datasource. Is this feasible with current version of API's?

 

Many Thanks,

 

Tim.

4 REPLIES 4
Super User II
Super User II

Re: Programmatically enter missing dataset credentials using API

Hi @timlin 

 

You can use my Powershell script to update the data source credentials. This powershell script is internally calling PowerBI REST API's

 

You can read the full article here

 

## Take Over DataSet

Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post

## update data source credentials

$BounGateway=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.GetBoundGatewayDataSources" -Method GET | ConvertFrom-Json


$UpdateUserCredential = @{
            credentialType ="Basic"
            basicCredentials = @{            
            username= $username
            password= "$(credentialpassword)"
            }
} | ConvertTo-Json



Invoke-PowerBIRestMethod -Url "gateways/$($BounGateway.value.gatewayId)/datasources/$($BounGateway.value.id)" -Method PATCH -Body $UpdateUserCredential | ConvertFrom-Json

 

Download the full source code from here







Did my reply helpful to you ? Please give Kudos

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




timlin
Frequent Visitor

Re: Programmatically enter missing dataset credentials using API

Thank you for your response Jay. I forgot to add that my dataset is owned by a service principal (SPN) rather than a user principal. Is this approach still feasible?

Super User II
Super User II

Re: Programmatically enter missing dataset credentials using API

Hi @timlin ,

 

Yes using SPN is feasable, infact if you read my article I've used SPN for the same







Did my reply helpful to you ? Please give Kudos

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Super User II
Super User II

Re: Programmatically enter missing dataset credentials using API

Hi @timlin ,

 

Do you any update ? If my replay helps you please mark as accepted 







Did my reply helpful to you ? Please give Kudos

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors