G
Guest
I get the following error when I send a HTTPWebRequest.
System.Net.WebException: The remote server returned an error: (500) Internal
Server Error. at System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.GetResponse()
Below is the code that I wrote.
-------------------------------------
Dim xmlDOM As New XmlDocument
xmlDOM.Load("C:/Subs_Req.xml")
Dim strxml As String = xmlDOM.OuterXml
Dim myxml As String = "xml=" & strxml
Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(myxml.ToString())
Dim xml As String = System.Web.HttpUtility.UrlEncode(myxml)
Dim myURL As String= "https://xxxxxx.com:443/xxxx".ToString
Dim myRequest As HttpWebRequest = CType(WebRequest.Create(myURL),
HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.ContentLength = data.Length
Dim NewStream As Stream = myRequest.GetRequestStream()
NewStream.Write(data, 0, data.Length)
NewStream.Close()
Dim myResponse As HttpWebResponse
myResponse = CType(myRequest.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader (myResponse.GetResponseStream())
Dim response As String = sr.ReadToEnd()
System.Net.WebException: The remote server returned an error: (500) Internal
Server Error. at System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.GetResponse()
Below is the code that I wrote.
-------------------------------------
Dim xmlDOM As New XmlDocument
xmlDOM.Load("C:/Subs_Req.xml")
Dim strxml As String = xmlDOM.OuterXml
Dim myxml As String = "xml=" & strxml
Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(myxml.ToString())
Dim xml As String = System.Web.HttpUtility.UrlEncode(myxml)
Dim myURL As String= "https://xxxxxx.com:443/xxxx".ToString
Dim myRequest As HttpWebRequest = CType(WebRequest.Create(myURL),
HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.ContentLength = data.Length
Dim NewStream As Stream = myRequest.GetRequestStream()
NewStream.Write(data, 0, data.Length)
NewStream.Close()
Dim myResponse As HttpWebResponse
myResponse = CType(myRequest.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader (myResponse.GetResponseStream())
Dim response As String = sr.ReadToEnd()