Hi - I am trying to insert data via web service. The code below writes to the database; however, I have an error (see bottom). What goes wrong here? and how to fix it?
//Create the web request
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
//Set type to POST
request.Method = "POST";
request.ContentType = "text/XML";
// Write data
using (StreamWriter postStream = new StreamWriter(request.GetRequestStream()))
{
postStream.WriteLine("<biz_in><phone_no>+1604333333</phone_no></biz_in>");
postStream.Dispose();
}
Error:
System.Net.WebException was unhandled Message="The request was aborted: The request was canceled." Source="System" StackTrace: at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting) at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState) at System.Net.ConnectStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.StreamWriter.Dispose(Boolean disposing) at System.IO.StreamWriter.Close() at ConsoleApplication1.Program.Main(String[] args) in C:/Program Files/Program.cs:line 62 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()