public WorkbooksApi testLogin()
        {
            loginParams = new Dictionary <string, object>();
            loginParams.Add("username", username);
            loginParams.Add("password", password);
            if (System.Environment.GetEnvironmentVariable("DATABASE_ID") != null)
            {
                loginParams.Add("logical_database_id", System.Environment.GetEnvironmentVariable("DATABASE_ID"));
            }
            workbooks.log("Login commences", new Object[] { this.GetType().Name });
            Dictionary <string, object> response = null;

            try {
                response = workbooks.login(loginParams);
                int http_status = (int)response["http_status"];
                Dictionary <string, object> responseData = (Dictionary <string, object>)response["response"];
                if (response.ContainsKey("failure_reason"))
                {
                    String failure_reason = response["failure_reason"].ToString();
                    if (http_status == WorkbooksApi.HTTP_STATUS_FORBIDDEN && failure_reason.Equals("no_database_selection_made"))
                    {
                        String default_database_id = responseData["default_database_id"].ToString();
                        loginParams.Add("logical_database_id", default_database_id);

                        response    = workbooks.login(loginParams);
                        http_status = (int)response["http_status"];
                        if (http_status != WorkbooksApi.HTTP_STATUS_OK)
                        {
                            workbooks.log("Login has failed", new Object[] { response }, "error");
                            System.Environment.Exit(0);
                        }
                    }
                }
                workbooks.log("Login complete", new Object[] { this.GetType().ToString() }, "info");
            } catch (Exception e) {
                workbooks.log("Exception: ", new Object[] { e }, "error");
            }
            return(workbooks);
        }