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

Problem to Modify Dataset Credential

Hello, i hope you´re doing well.

 

I´m having this issue every time i try to modify credential of the Dataset.

 

Invoke-PowerBIRestMethod : One or more errors occurred.
At C:\Users\ZN661HL\source\repos\ImportantStaff\CICD\ModifyDatasetCredential.ps1:61 char:16
+ ... $response= Invoke-PowerBIRestMethod -Url "gateways/$($BounGateway.va ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

 

 

 

This is the Code i´m using:

$datasetname = "DummyPBIDataset"
$workspacename = "CIT Datawarehouse - QA"

## user credentials

$username = "xxxxxxxxxxx"
$password = "xxxxxxxxx"
$client_secret_temp = "?xxxxxxxxx" | ConvertTo-SecureString -AsPlainText -Force
$client_id_temp = "xxxxxxxxxxxx"
$tenant_id_temp = "xxxxxxxxxxxxxxxxxx"


#$clientsec = "?YxX3q?f.Gk?OJxR4WUshAKjsB6NA1IJ" | ConvertTo-SecureString -AsPlainText -Force

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $client_id_temp$client_secret_temp
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenant_id_temp


##Getworksapce

$workspace = Get-PowerBIWorkspace -Name $workspacename

# GetDataSets
$DatasetResponse = Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json


# Get DataSet
$datasets = $DatasetResponse.value

#Iterate all Datasets to find Id of the DummnyDataset
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

#This Api is the recomended for Microsoft
#Retrieve the Dataset Gateway  
$BounGateway = Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/datasources" -Method GET | ConvertFrom-Json
$BounGateway
#This call to the Api was commented because the recomendation of microsoft to use another one
#$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

try
{
    $responseInvoke-PowerBIRestMethod -Url "gateways/$($BounGateway.value.gatewayId)/datasources/$($BounGateway.value.id)" -Method PATCH -Body $UpdateUserCredential | ConvertFrom-Json 
    $response
}
catch 
{
    Write-Host "An error occurred:"
    Write-Host $_
}
finally
{
}




 

#$response
 
 
Thank you @Jayendran  for any help in advance.
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Problem to Modify Dataset Credential

Hi @arceo-javier ,

 

I'm not sure you are using SPN or master account. In either of the case please make sure to give access to the workspace as admin.

 

Then you make sure to take over the dataset before udpating the credentials ? 

 

As the error saying it's not found. May be you are missing either of the above two.

 

For AzureSQL i don't think you need on-premises Data gateway. But the bounddefault gateway should always need ,which is quite different from the typical on-premises data gateway.







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!




View solution in original post

7 REPLIES 7
Highlighted
Super User II
Super User II

Re: Problem to Modify Dataset Credential

Hi @arceo-javier ,

 

Powershell is poor at giving the exact error especially for REST API calls. Could you please install the fiddler and try to get what is the exact error ? With the exact error only we can able to move forward for the solution.







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!




Highlighted
Frequent Visitor

Re: Problem to Modify Dataset Credential

Sorry, here the error i´m getting :

 

HTTP/1.1 404 Not Found
Cache-Control: no-store, must-revalidate, no-cache
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/json; odata.metadata=minimal
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: deny
X-Content-Type-Options: nosniff
RequestId: 52113063-e1ce-45ba-979d-1760cd5e88a4
OData-Version: 4.0
Access-Control-Expose-Headers: RequestId
request-redirected: true
home-cluster-uri: https://wabi-europe-north-b-redirect.analysis.windows.net/
Date: Tue, 16 Jun 2020 14:59:18 GMT

EB
{
"error":{
"code":"","message":"No HTTP resource was found that matches the request URI 'http://wabi-europe-north-b-redirect.analysis.windows.net/v1.0/myorg/gateways/7f7807d7-c24a-42e4-b578...'."
}
}
0

 

I´m using this code to retrieve the gateway:

 

i took this code from your ci cd pipeline  @Jayendran

 

 

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

 

i already tried using the power bi UI to update credential and i was able to do it, but i realize that gateway.id and datasource id were diferents. 

 

This is what i get from power bi UI.

 

This is using Invoke-PowerBIRestMethod

gatewayid=7f7807d7-c24a-42e4-b578-f3fb418980bb

datasourceid=846f9253-72f4-4f85-abcd-04ee75e5dce5

 

completly diferents.

 

 

 

Highlighted
Super User II
Super User II

Re: Problem to Modify Dataset Credential

Hi @arceo-javier ,

 

Both gateways are totally different you should not compare it. The boundgateway is used by microsoft behind the screen in other hand the gateway url which you got is the one which you installed it.

 

What is your data source ? Is that a cloud or on-premises (using any on-premiese datagateway) ?

 







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!




Highlighted
Frequent Visitor

Re: Problem to Modify Dataset Credential

Hi @Jayendran ,

 

I´m using Azure Sql Server, i don´t remember having installed a gateway.

 

might it have installed because i'm using a vpn to connect to azure sql server?

 

 

Highlighted
Super User II
Super User II

Re: Problem to Modify Dataset Credential

Hi @arceo-javier ,

 

I'm not sure you are using SPN or master account. In either of the case please make sure to give access to the workspace as admin.

 

Then you make sure to take over the dataset before udpating the credentials ? 

 

As the error saying it's not found. May be you are missing either of the above two.

 

For AzureSQL i don't think you need on-premises Data gateway. But the bounddefault gateway should always need ,which is quite different from the typical on-premises data gateway.







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!




View solution in original post

Highlighted
Frequent Visitor

Re: Problem to Modify Dataset Credential

Thank you @Jayendran , you were right i was missing take over dataset before update credential.

 

one more time thank you.

 

Highlighted
Super User II
Super User II

Re: Problem to Modify Dataset Credential

@arceo-javier  glad to help







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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.