Esempio n. 1
0
        private static string SendGetRequest(string url, string spartanToken, RequestAuthType authType)
        {
            var noCache = string.Format(url.Contains("?") ? "&_={0}" : "?_={0}", Environment.TickCount);

            var request = (HttpWebRequest)WebRequest.Create(new Uri(url + noCache));

            request.Method = HttpMethod.Get;
            request.Accept = "application/json";

            switch (authType)
            {
            case RequestAuthType.Spartan:
                request.Headers["X-343-Authorization-Spartan"] = spartanToken;
                break;
            }

            var response = request.GetResponseAsync().Result;
            var stream   = response.GetResponseStream();

            return(stream == null ? null : new StreamReader(stream).ReadToEnd());
        }
Esempio n. 2
0
        private static string SendGetRequest(string url, string spartanToken, RequestAuthType authType)
        {
            var noCache = string.Format(url.Contains("?") ? "&_={0}" : "?_={0}", Environment.TickCount);

            var request = (HttpWebRequest)WebRequest.Create(new Uri(url + noCache));

            request.Method = HttpMethod.Get;
            request.Accept = "application/json";

            switch (authType)
            {
                case RequestAuthType.Spartan:
                    request.Headers["X-343-Authorization-Spartan"] = spartanToken;
                    break;
            }

            var response = request.GetResponseAsync().Result;
            var stream = response.GetResponseStream();

            return stream == null ? null : new StreamReader(stream).ReadToEnd();
        }