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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Error Invoke-PowerBIRestMethod Default.UpdateDatasource

For a couple of years we are using on Azure Devops a powershell script for Power BI Embedded with 2 consecutive lines:
1) Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($dataset.id)/Default.TakeOver" -Method Post -Verbose
2) Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($dataset.id)/Default.UpdateDatasources" -Method Post

    -Body $UpdateDatabaseBody -Verbose

 

The first line work fine.
But since 30-10-2023 we have problems with the second line. We get the exception “Dataset doesn't contain a datasource that matches selector #1”. Unclear to me what the selector is and why it gives an error after years of running. 

 

 

 

Status: Investigating
Comments
Anonymous
Not applicable

Hi  @Anonymous 

Make sure that the dataset you are targeting in your script has at least one data source defined. You can check this in the Power BI service by navigating to the dataset's settings and reviewing the data sources section.

 

The error message also mentions a selector (#1). It's possible that the selector you are using in the `$UpdateDatabaseBody` variable is not matching any data sources in the dataset. Double-check the selector value and ensure it corresponds to a valid data source in the dataset.

 

Best Regards,
Community Support Team _ Ailsa Tao

Anonymous
Not applicable

The selector $UpdateDatabaseBody is defined as:

$UpdateDatabaseBody = @"

               {

                 "updateDetails":[

                              {

                                "connectionDetails":

                                {

                                            "server": "$NewSqlServer",

                                            "database": "$Database"

                                },

                                "datasourceSelector":

                                {

                                            "datasourceType": "Sql",

                                            "connectionDetails":

                                            {

                                              "server": "$OldSqlServer",

                                              "database": "$Database"

                                            }

                                }

                              }

                 ]

               }

"@

 

De parameters "$NewSqlServer", "$Database", "$OldSqlServer" are used in a previous step for updating  Entity Framework. This works fine.

I tested the values first with both SQL Server Manegement Studio and by changing the values in PowerBi Desktop as you mentioned and that works fine. So the values are correct. We use these values a couple of years.

 

The last time the deploy works correct was on 26 october 2023. We did a re-deploy of the same release on 30-10-2023 and it gives the error I mentioned. And since then all other attempts failed with this error. I suspect something is updated in Azure DevOps with PowerBi Embedded / PowerBi Services.

 

Anonymous
Not applicable

Solution found! We have a powershell script for updating and deleting reports. When deleting a report, there is still a dataset in the workspace with this name. We didn't expect that and it caused an error when iterating the datasets. Deleting the report together with the dataset, solved this issue.