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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply

How can I changes SQL database server , database name and credential of an published report ?

How can I change the SQL database server, database name and credential of a published report?

 

By published the report from SQL server credential and implement parameterized Sql server and Sql DB name , we can able to change DB name parameter by calling PowerBI APIs , but how I can change Sever Name? 

I have tried "Default.UpdateDatasources"  but its change only server name and DB name , not its credential ?

 

Please help me out as early as possible

 

TIA

Paritosh Mishra  

1 ACCEPTED SOLUTION

Its solve by first DB server and DB name  then   calling "Default.UpdateDatasources"
then  by calling "gateways/$gatewayId/datasources/$datasourceId" 

 

Thanks 

View solution in original post

3 REPLIES 3

I have changed the DB server and its credential only to those which I had recently inputs on Power BI Web .May be DB credential are kept in caches .
If I have used new DB server and its credential , then only DB server and DB name changes .Password changed script thow error  "The remote server returned an error: (400) Bad Request" 

This is my code of password change .

I am not using Gateway.

########## Change Password  #########

$datasourePatchUrl = "https://api.powerbi.com/v1.0/myorg/gateways/$gatewayId/datasources/$datasourceId"

$patchBody = @{
"credentialDetails" = @{
"credentials" = "{""credentialData"":[{""name"":""username"",""value"":""$sqlUserName""},{""name"":""password"",""value"":""$sqlUserPassword""}]}"
"credentialType" = "Basic"
"encryptedConnection" = "NotEncrypted"
"encryptionAlgorithm" = "None"
"privacyLevel" = "Organizational"
}
}

$patchBodyJson = ConvertTo-Json -InputObject $patchBody -Depth 6 -Compress

$response = Invoke-RestMethod -Uri $datasourePatchUrl –Headers $auth_header -Body $patchBodyJson –Method PATCH

########## Change Password  #########

So my queries are
1. How this changes password script run successfully even in new DB server
2. How the Power BI online caches (where Db credential stored) delete .

Please help  me out 
TIA

nickyvv
Most Valuable Professional
Most Valuable Professional

Hi @paritoshmishra,

if you are using a gateway you could use Gateways - Update Datasource.

 



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

Blog: nickyvv.com | @NickyvV


Its solve by first DB server and DB name  then   calling "Default.UpdateDatasources"
then  by calling "gateways/$gatewayId/datasources/$datasourceId" 

 

Thanks 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.