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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Neehar
Helper I
Helper I

Operation is not supported for selector # - connection details contains parameters

Hi,

 

I have a Problem Updating the Server details in the dataset of uploaded power bi Report

 

Here I used 2 approaches

1) Used the below method in Microsoft.PowerBI.Api.V2

 

 

 

 

public static void UpdateSqlDatabaseConnectionString(string WorkspaceId, string DatasetId, string Server, string Database)
        {
            var tokenCredentials = GetTokenCredentials();
            using (var pbiClient = new PowerBIClient(new Uri(ApiUrl), tokenCredentials.Item1))
            {
                Datasource targetDatasource = pbiClient.Datasets.GetDatasourcesInGroup(WorkspaceId, DatasetId).Value.First();

                string currentServer = targetDatasource.ConnectionDetails.Server;
                string currentDatabase = targetDatasource.ConnectionDetails.Database;

                if (Server.ToLower().Equals(currentServer.ToLower()) && Database.ToLower().Equals(currentDatabase.ToLower()))
                {
                    Console.WriteLine("New server and database name are the same as the old names");
                    return;
                }

                DatasourceConnectionDetails connectionDetails = new DatasourceConnectionDetails
                {
                    Database = Database,
                    Server = Server
                };

                UpdateDatasourceConnectionRequest updateConnRequest =
                  new UpdateDatasourceConnectionRequest
                  {
                      DatasourceSelector = targetDatasource,
                      ConnectionDetails = connectionDetails
                  };

                UpdateDatasourcesRequest updateDatasourcesRequest = new UpdateDatasourcesRequest(updateConnRequest);
                pbiClient.Datasets.UpdateDatasourcesInGroup(WorkspaceId, DatasetId, updateDatasourcesRequest);
            }
        }

 

 

 

Captured the request in fiddler

 

Request:

 

 

{
  "updateDetails": [
    {
      "connectionDetails": {
        "server": "OldServer",
        "database": "OldDatabase"
      },
      "datasourceSelector": {
        "datasourceType": "Sql",
        "connectionDetails": {
          "server": "NewServer",
          "database": "NewDatabase"
        },
        "gatewayId": "gatewayId",
        "datasourceId": "datasourceId"
      }
    }
  ]
} 

 

 

 

Response :

 

 

 

{"error":{"code":"InvalidRequest","message":"Operation is not supported for selector # - connection details contains parameters"}}

 

 

 

Approach 2
Called the Power BI rest API

 

 

 

 

public static void UpdateServerName_RestAPI(string groupId, string datasetId)
                        {
                            var tokenCredentials = GetTokenCredentials();
                            HttpResponseMessage response;
                            try
                            {
                                var httpClient = new HttpClient();
                
                                // Add AccessToken in header
                                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenCredentials.Item2);
                
                                var url = $"https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/Default.UpdateDatasources";
                
                                var form = prepareJsonForUpdateServerDetails();
                
                                var content = new StringContent(form, Encoding.UTF8, "application/json");
                
                                response = httpClient.PostAsync(url, content).Result;
                
                                response.EnsureSuccessStatusCode();
                                httpClient.Dispose();
                            }
                            catch (Exception)
                            {
                                
                            }
                        }

 

 

 

Request :

 

 

 

{
   "UpdateDetails":[
      {
         "datasourceSelector":{
            "datasourceType":"Sql",
            "connectionDetails":{
               "server":"OldServer",
               "database":"OldDatabase"
            }
         },
         "connectionDetails":{
            "server":"NewServer",
            "database":"NewDatabase"
         }
      }
   ]
}

 

 

 

Response

 

 

 

HTTP/1.1 400 Bad Request
Cache-Control: no-store, must-revalidate, no-cache
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: deny
X-Content-Type-Options: nosniff
RequestId: e77763b8-e0f0-4ec0-9c97-d2a5cf3287d4
Access-Control-Expose-Headers: RequestId
request-redirected: true
home-cluster-uri: https://wabi-india-central-a-primary-redirect.analysis.windows.net/
Date: Sun, 10 Oct 2021 13:53:05 GMT

82
{"error":{"code":"InvalidRequest","message":"Operation is not supported for selector # - connection details contains parameters"}}
0

 

 

 

Please Help.

Thank You

 

 

 

 

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @Neehar,

What type of data source are you worked on? Did these configurations correctly match with your data source types? Did you parameterize your connecting string with query parameters? Please share some more detailed information to help us clarify your scenario.

How to Get Your Question Answered Quickly 

In addition, have you checked the new data source to confirm the new one has the same schema as the old one? You can also take a look at the limitation of update rest API:
Datasets - Update Datasources - REST API (Power BI Power BI REST APIs) | Microsoft Docs

Datasets - Update Parameters - REST API (Power BI Power BI REST APIs) | Microsoft Docs

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft ,

 

Firstly, Thanks for the reply.

 

Here is the complete scenario.

We are moving the reports in power bi to a different tenant. So we want to update the server details of the power bi report in the datasets section.

 

I tried the above mentioned 2 scenarios but facing the issue.

Below are my inline comments for your questions.

 

  1. What type of data source are you worked on?" : sql (azure sql).
  2. Did these configurations correctly match with your data source types ? Yes 
  3. Did you parameterize your connecting string with query parameters ? No

 

Thank You.

 

 

 

 

 

Hi @Neehar,

I think these should be related to your cross-tenant operations. AFAIK, current power bi does not support directly sharing the gateway between different tenants.

Did the device that you installed the gateway has corresponding permission and proxy setting that can be accessed from another tenant?  

If not, I think you may need to do a cross-tenant mapping operation on your device at the first. Then your gateway client can be viewed the data source that hosts on another tenant.

One on-premis AD, multiple AAD tenants - Microsoft Q&A

BTW, you can take a look at following document about Multi-tenancy solutions if helps:

Power BI embedded analytics multi-tenancy solutions - Power BI | Microsoft Docs

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.