March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I'm new to PowerBI but not to PowerShell.
I've got a dataset which is a Web type and is coming from Azure API. The credentials are anonymous, the parameters handle the authentication eg apikey and so on.
I want to refresh it automatically each day using the service principal. I can do the take over of the dataset and initiate a refresh as the SP, but it then fails due to an error validating the source credentials. If i could actually skip this section it would just work.
So i am now trying to perform creating a new Web type Anonymous credential with PowerShell as the SP but I'm hitting some bugs.
Here is my credential setting in the powerbi gui:
However, after my SP takes over the dataset and tries to refresh it, i get this dreaded error. SO i assume I need to update / delete and recreate the credentials.
I followed something from the MS PowerBI Github that is very similar but for a SQL source: PowerShell
I've edited the code slightly to look like this, but i still get a generic 500 error.
# create HTTP request body to update datasource connection details
$postBody = @{
"updateDetails" = @(
@{
"connectionDetails" = @{
"url" = "https://xxx.azure-api.net/"
}
"datasourceSelector" = @{
"datasourceType" = "Web"
"connectionDetails" = @{
"url" = "https://xxx.azure-api.net/"
}
"gatewayId" = "$gatewayId"
"datasourceId" = "$datasourceId"
}
})
}
# convert body contents to JSON
$postBodyJson = ConvertTo-Json -InputObject $postBody -Depth 6 -Compress
# execute POST operation to update datasource connection details
Invoke-PowerBIRestMethod -Method Post -Url $datasourePatchUrl -Body $postBodyJson
I've also tried it like this:
$New = @{
dataSourceType = "Web"
datasourceName = "Dummy Web Connection"
connectionDetails = "{`"url`":`"https://xxx.azure-api.net/`"}"
credentialDetails = @{
credentialType = "Anonymous"
credentials = "{`"credentialData`":`"`"}"
encryptedConnection = "NotEncrypted"
encryptionAlgorithm = "None"
privacyLevel = "None"
}
} | ConvertTo-Json
Invoke-PowerBIRestMethod -Url "gateways/$GatewayId/datasources/" -Method Post -Body $new -Verbose
However in fiddler i get the following:
A7 {"error":{"code":"DMTS_InvalidEncryptionAlgorithmError","pbi.error":{"code":"DMTS_InvalidEncryptionAlgorithmError","parameters":{},"details":[],"exceptionCulprit":1}}} 0
My source type is web and credential type is anonymous. There is no username or password, this should be really straightforward but I am finding it very difficult to overcome this issue - hoping someone can help.
Any help appreciated!
Hi
So is there a solution check the "skip test connection" checkbox for a service principal??
Hi @sweggle ,
Please review the content in the following threads, hope they can help you.
Power BI: Using anonymous authentication on Web data sources with a API key in URL
How to update credentials for an on-prem Power BI data source using PowerShell
Best Regards
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 |