public AuthResponsev6 testRestConnectionv6()
        {
            String URL = this.RestEndpointURL + ":" + this.RestAuthEndpointPort + "/v1/authentication";

            string json = "{ \"username\" : \"" + this.RestLogin + "\", \"password\" : \"" + this.RestPassword + "\" }";
            //Console.WriteLine("Debug:" + URL+":"+json);
            RestResponse resp = RestUtils.SendAuthRequest(URL, json, this.IQBotMajorVersion);

            if (resp.ORetCode != 0)
            {
                Console.WriteLine(" -- Error Code: " + resp.ORetCode);
                return(null);
            }
            else
            {
                //AuthResponsev6_401
                AuthResponsev6 r = JsonConvert.DeserializeObject <AuthResponsev6>(resp.RetResponse);

                if (r.token == null)
                {
                    Console.WriteLine(" -- Error: REST Authentication failed.");
                    this.RestAuthToken = null;
                    return(null);
                }

                this.RestAuthToken = r.token;
                return(r);
            }
        }
        public IQBotConnectionBroker(int MajorVersion, String RestBaseURI, int RestAuthPort, String Login, String Password, int AliasServicePort)
        {
            this.RestEndpointURL      = RestBaseURI;
            this.RestAuthEndpointPort = RestAuthPort;
            this.RestLogin            = Login;
            this.RestPassword         = Password;
            this.RestAliasPort        = AliasServicePort;
            this.IQBotMajorVersion    = MajorVersion;
            //this.CRPort = CRPort;

            Boolean ConnectionIsOK = false;

            switch (this.IQBotMajorVersion)
            {
            case 6:
                authres6 = testRestConnectionv6();
                if (authres6 != null)
                {
                    ConnectionIsOK = true;
                }
                break;

            default:
                Console.WriteLine("-- Error, IQ Bot Version not supported: " + this.IQBotMajorVersion);
                Environment.Exit(-1);
                break;
            }


            if (!ConnectionIsOK)
            {
                Console.WriteLine(" -- Error: REST Connection Could Not Be Established.");
                Console.ReadKey();
                System.Environment.Exit(1);
            }
            IsRestConnectionOK = true;
        }