Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48330

Re: Unable to update credentials via REST API?

$
0
0

Hi  ,

 

If you want you can use my powershell script where i did the same Basic update credentials without having any issues

 

$applicationId = "" # Need to pass the clientid from devops variable $clientsec = "" | ConvertTo-SecureString -AsPlainText -Force # Need to pass from devops secret variable $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "" # Need to pass from devops variable $workspacename="PowerBI_CICD_PROD" $datasetname="AdventureReports" ## user credentials $username= "sadmin" $password= "Password@123" # Need to pass from devops secret variable ##Getworksapce $workspace =Get-PowerBIWorkspace -Name $workspacename # GetDataSets $DatasetResponse=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json # Get DataSet $datasets = $DatasetResponse.value foreach($dataset in $datasets){ if($dataset.name -eq $datasetname){ $datasetid= $dataset.id; break; } } ## 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=$password } } | ConvertTo-Json Invoke-PowerBIRestMethod -Url "gateways/$($BounGateway.value.gatewayId)/datasources/$($BounGateway.value.id)" -Method PATCH -Body $UpdateUserCredential | ConvertFrom-Json ## update parameter API $postParams = @{ updateDetails =@( @{ name="blob" newValue="https://demo.blob.core.windows.net/" } ) } | ConvertTo-Json Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.UpdateParameters" -Method Post -Body $postParams | ConvertFrom-Json

 

 


Viewing all articles
Browse latest Browse all 48330

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>