private async Task LogOnAsync(string site = "")
        {
            var j = ToJson((new SignIn(User, Password, site)));

            var request = new HttpRequestMessage(HttpMethod.Post, "3.3/auth/signin")
            {
                Content = new StringContent(j, Encoding.UTF8, "application/json")
            };

            try
            {
                var response = await Client.SendAsync(request);

                if (response.IsSuccessStatusCode)
                {
                    var l = await response.Content.ReadAsAsync <SignIn>();

                    LogOn = l.Credentials;
                }
                else
                {
                    await Error.ManageHttpErrorAsync(response);
                }
            }
            catch (Exception ex)
            {
                Error.Error.Detail = ex.Message;
                throw ex;
            }
        }
 public SignIn(string name, string password, string site)
 {
     Credentials = new ServerCredentials
     {
         Name     = name,
         Password = password,
         Site     = new ServerSite {
             ContentUrl = site
         }
     };
 }
        private async Task SwitchSiteAsync(string site)
        {
            var switchSite = new Site
            {
                SiteDetails = new ServerSite
                {
                    ContentUrl = site
                }
            };

            var j = ToJson(switchSite);

            Client.DefaultRequestHeaders.Remove("X-Tableau-Auth");
            Client.DefaultRequestHeaders.TryAddWithoutValidation("X-Tableau-Auth", LogOn.Token);

            var request = new HttpRequestMessage(HttpMethod.Post, "3.3/auth/switchsite")
            {
                Content = new StringContent(j, Encoding.UTF8, "application/json")
            };

            try
            {
                var response = await Client.SendAsync(request);

                if (response.IsSuccessStatusCode)
                {
                    var l = await response.Content.ReadAsAsync <SignIn>();

                    LogOn = l.Credentials;
                }
                else
                {
                    Error.HasError = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }