Click here to Skip to main content
15,912,021 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(APIURL);

string strData = null;
            
            strData = "-------- data to assign---------";
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] data = encoding.GetBytes(strData);

            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            request.KeepAlive = true;
            request.UserAgent = "Custom Agent";
            request.ContentLength = data.Length;
            request.AllowAutoRedirect = true;
            request.Timeout = (int)new TimeSpan(0, 0, 60).TotalMilliseconds;
            request.ServicePoint.Expect100Continue = false;

	    Stream newStream = request.GetRequestStream();

I getting above error at following line

C#
Stream newStream = request.GetRequestStream();
Posted
Comments
Richard MacCutchan 8-Sep-15 4:09am    
Probably because your system cannot get a connection to the remote. Check it out with a browser to make sure your URI is correct.
Kailas_ 8-Sep-15 4:13am    
Yes as I expected, I m not getting that URI in browser, and I just want to make sure that error is really there only, right.??

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