Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register 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
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |