0 Replies Latest reply on Jul 2, 2014 2:03 PM by rushi.v

    Add/delete user to Tableau Server - implementation in C#

    rushi.v

      Hi,

       

      I have used this Tableau Server WebService Authentication C# as reference to authenticate user and generate token. Can someone help me in continuing this implementation to add users to server.

      As we already have authenticity token, what calls should be made to Tableau server to add users/delete users from web application ? I see here it is implemented in Ruby but hard to understand as I have never done ruby before  tableau_ldap_sync/lib/tableau_ldap_sync/tableau.rb at master · tfoldi/tableau_ldap_sync · GitHub

      can someone help in converting this to C# with functionality to add users by local trusted authentication

       

       

      This is what I have so far. I m not sure If I m passing write parameters or calling the right API for adding new user in Tableau. This is the error message: Internal Server Error

       

      Any help to this is appreciated :

       

          private async Task<HttpResponseMessage> PostUser(string authenticityToken, string newUser)
              {
                  using (var multipartFormDataContent = new MultipartFormDataContent())
                  {
                      var values = new[]  
                                  {  
                                      //new KeyValuePair<string, string>("target_site", _site),  
                                      new KeyValuePair<string, string>("authenticity_token", authenticityToken), 
                                      new KeyValuePair<string, string>("step", "1"),  
                                      new KeyValuePair<string, string>("name", newUser), 
                                      new KeyValuePair<string, string>("level", "interactor") 
                                  };
                      foreach (var keyValuePair in values)
                      {
                          multipartFormDataContent.Add(new StringContent(keyValuePair.Value),
                              String.Format("\"{0}\"", keyValuePair.Key));
                      }
      
                      HttpResponseMessage createUserTask = await _client.PostAsync("manual/create/users", multipartFormDataContent);
                      var result = createUserTask.IsSuccessStatusCode;
                      return result;
                  }
              }