Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am getting an error when i request to linke in access token url uing socail Oauth 2.0


The line request.GetResponse() getting this error.

What I have tried:

C#
public static string Request(string url, string method, string contentType, NameValueCollection header,
            string data, string proxyAddress = null)
        {
            var request = (HttpWebRequest) WebRequest.Create(url);
            request.Method = method;
            if (!string.IsNullOrEmpty(contentType))
                request.ContentType = contentType;
            if (header != null)
                request.Headers.Add(header);

            if (!string.IsNullOrEmpty(proxyAddress))
            {
                IWebProxy proxy = new WebProxy(proxyAddress);
                proxy.Credentials = new NetworkCredential();
                request.Proxy = proxy;
            }

            if (!string.IsNullOrEmpty(data))
            {
                using (var swt = new StreamWriter(request.GetRequestStream()))
                {
                    swt.Write(data);
                }
            }

            string result = string.Empty;
            using (WebResponse response = request.GetResponse())
            {
                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    result = sr.ReadToEnd();
                }
            }
            return result;
        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900