Esempio n. 1
0
        public string GetMonitors(string authToken)
        {
            string result = string.Empty;

            try
            {
                string query        = string.Format("{0}={1}", "authtoken", authToken);
                string actionString = string.Format("{0}/{1}", "api", "monitors");
                var    urlBuilder   = HttpSendData.GetUrlBuilder(APIType.SITE24X7_API, actionString, query);
                var    responseObj  = HttpSendData.SendData(urlBuilder.Url, null, true, null, MethodType.GET);

                if (responseObj != null)
                {
                    responseObj.Wait();
                    result = responseObj.Result.ToString();
                }
                else
                {
                    result = "{\"error_code\":9999,\"message\":\"response is null.\"}";
                }
            }
            catch (Exception ex)
            {
                result = "{\"error\":9999,\"message\":\" " + ex.ToString() + " \"}";
            }
            return(result);
        }
Esempio n. 2
0
        public string GetUser(string authToken)
        {
            string result = string.Empty;

            try
            {
                string query        = string.Format("{0}={1}", "authtoken", authToken);
                string actionString = string.Format("{0}/{1}", "api", "users");
                var    urlBuilder   = HttpSendData.GetUrlBuilder(APIType.SITE24X7_API, actionString, query);
                var    responseObj  = HttpSendData.SendData(urlBuilder.Url, null, true, null, MethodType.GET);

                if (responseObj != null)
                {
                    responseObj.Wait();
                    result = responseObj.Result.ToString();
                }
                else
                {
                    result = "NULL";
                }
            }
            catch
            {
            }
            return(result);
        }
Esempio n. 3
0
        public string RetrieveCurrentStatus(string authToken)
        {
            string result = string.Empty;

            try
            {
                string query        = string.Format("{0}={1}&{2}={3}&{4}={5}", "authtoken", authToken, "widget_required", "false", "apm_required", "true");
                string actionString = string.Format("{0}/{1}", "api", "current_status");
                var    urlBuilder   = HttpSendData.GetUrlBuilder(APIType.SITE24X7_API, actionString, query);
                var    responseObj  = HttpSendData.SendData(urlBuilder.Url, null, true, null, MethodType.GET);

                if (responseObj != null)
                {
                    responseObj.Wait();
                    result = responseObj.Result.ToString();
                }
                else
                {
                    result = "{\"error_code\":9999,\"message\":\"response is null.\"}";
                }
            }
            catch (Exception ex)
            {
                result = "{\"error\":9999,\"message\":\" " + ex.ToString() + " \"}";
            }
            return(result);
        }
Esempio n. 4
0
        public string GetAuthToken(string userName, string password)
        {
            string authToken = string.Empty;

            try
            {
                var body = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("SCOPE", "Site24x7/site24x7api"),
                    new KeyValuePair <string, string>("EMAIL_ID", userName),
                    new KeyValuePair <string, string>("PASSWORD", password),
                };
                string actionString = string.Format("{0}/{1}/{2}", "apiauthtoken", "nb", "create");
                var    urlBuilder   = HttpSendData.GetUrlBuilder(APIType.ZOHO_ACCOUNT, actionString, string.Empty);
                var    responseObj  = HttpSendData.PostData(urlBuilder.Url, body);

                if (responseObj != null)
                {
                    responseObj.Wait();
                    authToken = ResponseParser.ParseAuthToken(responseObj.Result);
                }
            }
            catch
            {
            }
            return(authToken);
        }