public CxRESTApiLoginResponse Login()
        {
            CxRESTApiLoginResponse cxRESTApiLoginResponse = new CxRESTApiLoginResponse();

            try
            {
                Uri            uri                    = GetLoginUri();
                string         messageBody            = GetMesageBody();
                byte[]         messageBodyAsByteArray = GetMesageBodyEncoded();
                HttpWebRequest webRequest             = CreateWebRequest(uri, messageBody, messageBodyAsByteArray);
                HandleWebResponse(cxRESTApiLoginResponse, webRequest);
            }
            catch (Exception ex)
            {
                Logger.Create().Error("CxRESTApiLogin->Login: " + ex.ToString());
                throw new WebException(ex.ToString());
            }

            return(cxRESTApiLoginResponse);
        }
        private void HandleWebResponse(CxRESTApiLoginResponse cxRESTApiLoginResponse, HttpWebRequest webRequest)
        {
            HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

            cxRESTApiLoginResponse.ResponseStatusCode = webResponse.StatusCode;

            if (webResponse.StatusCode != HttpStatusCode.OK)
            {
                Logger.Create().Error("CxRESTApiLogin->Login->Rest API, status message: " + webResponse.StatusDescription);
            }
            else
            {
                cxRESTApiLoginResponse.IsSuccessful = true;
            }

            Common.Web.Cookies.FillWebReponseCookies(webRequest, webResponse);
            LoginHelper.RESTApiCookies = webResponse.Cookies;
            new CxRESTApiPortalConfiguration().InitPortalBaseUrl();

            Common.Web.Cookies.SetCookiesInTheInternalBrowser(webResponse, LoginHelper.PortalConfiguration.WebServer);
        }