Ards_v6_Tester.RestClient.DoGet C# (CSharp) Метод

DoGet() публичный статический Метод

public static DoGet ( string requestUrl, string authToken ) : string
requestUrl string
authToken string
Результат string
        public static string DoGet(string requestUrl, string authToken)
        {
            try
            {
                var httpWReq = (HttpWebRequest)WebRequest.Create(requestUrl);

                var encoding = new ASCIIEncoding();

                httpWReq.Method = "GET";
                httpWReq.Accept = "application/json";
                httpWReq.ContentType = "application/json";
                httpWReq.Headers.Add("Authorization", authToken);

                var response = (HttpWebResponse)httpWReq.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.InternalServerError)
                {
                    string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                    try
                    {
                        var x = JToken.Parse(responseString).ToString(Newtonsoft.Json.Formatting.Indented);
                        return x;
                    }
                    catch
                    {
                        return responseString;
                    }
                }
                return string.Empty;

            }
            catch (Exception e)
            {
                return e.Message;
            }
        }