title: PowerBIAPI - Operation is not supported for selector # - connection details contains parameters" - update ServerName in PowerBI Dataset of the Report
body: <p>I have a Problem Updating the Server details in the dataset of the uploaded power bi Report. Please Help.</p>
  <p>Here I used 2 approaches.</p>
  <p><strong>Approach 1</strong></p>
  <ol>
  <li><p>Used the below method in <strong>Microsoft.PowerBI.Api.V2</strong>
  <strong>UpdateDatasourcesInGroup</strong></p>
  <pre><code>         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()) &amp;&amp; Database.ToLower().Equals(currentDatabase.ToLower()))
                   {
                       Console.WriteLine(&quot;New server and database name are the same as the old names&quot;);
                       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);
               }
           }
  </code></pre>
  </li>
  </ol>
  <p>Captured the request in fiddler</p>
  <p><strong>Request:</strong></p>
  <pre><code>{
    &quot;updateDetails&quot;: [
      {
        &quot;connectionDetails&quot;: {
          &quot;server&quot;: &quot;OldServer&quot;,
          &quot;database&quot;: &quot;OldDatabase&quot;
        },
        &quot;datasourceSelector&quot;: {
          &quot;datasourceType&quot;: &quot;Sql&quot;,
          &quot;connectionDetails&quot;: {
            &quot;server&quot;: &quot;NewServer&quot;,
            &quot;database&quot;: &quot;NewDatabase&quot;
          },
          &quot;gatewayId&quot;: &quot;gatewayId&quot;,
          &quot;datasourceId&quot;: &quot;datasourceId&quot;
        }
      }
    ]
  } 
  </code></pre>
  <p><strong>Response:</strong></p>
  <pre><code>{&quot;error&quot;:{&quot;code&quot;:&quot;InvalidRequest&quot;,&quot;message&quot;:&quot;Operation is not supported for selector # - connection details contains parameters&quot;}}
  </code></pre>
  <p><strong>Approach 2</strong></p>
  <p><strong>Called the Power BI rest API</strong></p>
  <pre><code>                        public static void UpdateServerName_RestAPI(string groupId, string datasetId)
                          {
                              var tokenCredentials = InitPowerBI_New();
                              HttpResponseMessage response;
                              try
                              {
                                  var httpClient = new HttpClient();
                  
                                  // Add AccessToken in header
                                  httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(&quot;Bearer&quot;, tokenCredentials.Item2);
                  
                                  var url = $&quot;https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/Default.UpdateDatasources&quot;;
                  
                                  var form = prepareJsonForUpdateServerDetails();
                  
                                  var content = new StringContent(form, Encoding.UTF8, &quot;application/json&quot;);
                  
                                  response = httpClient.PostAsync(url, content).Result;
                  
                                  response.EnsureSuccessStatusCode();
                                  httpClient.Dispose();
                              }
                              catch (Exception)
                              {
                                  
                              }
                          }
  </code></pre>
  <p><strong>Request :</strong></p>
  <pre><code>{
     &quot;UpdateDetails&quot;:[
        {
           &quot;datasourceSelector&quot;:{
              &quot;datasourceType&quot;:&quot;Sql&quot;,
              &quot;connectionDetails&quot;:{
                 &quot;server&quot;:&quot;OldServer&quot;,
                 &quot;database&quot;:&quot;OldDatabase&quot;
              }
           },
           &quot;connectionDetails&quot;:{
              &quot;server&quot;:&quot;NewServer&quot;,
              &quot;database&quot;:&quot;NewDatabase&quot;
           }
        }
     ]
  }
  </code></pre>
  <p><strong>Response:</strong></p>
  <pre><code>{&quot;error&quot;:{&quot;code&quot;:&quot;InvalidRequest&quot;,&quot;message&quot;:&quot;Operation is not supported for selector # - connection details contains parameters&quot;}}
  </code></pre>
  <p>Please Help.
  Thank You</p>