G
Guest
Hi
I am trying to POST to a URL using the HTTPWebRequest object
straight forward
ASCIIEncoding encoding = new ASCIIEncoding()
string s = "username=66"
HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create("http://url:8081/sendSMS/SendSMS"
wreq.Method="POST"
// Set the content type of the data being posted
wreq.ContentType = "application/x-www-form-urlencoded";//"Text/XML"
byte[] byte1 = encoding.GetBytes(s)
wreq.ContentLength = byte1.Length
try{Stream stream = wreq.GetRequestStream()
stream.Write(byte1, 0, byte1.Length)
stream.Close()
WebResponse wresp = wreq.GetResponse()
byte1 = new Byte[wresp.ContentLength]
stream = wresp.GetResponseStream()
stream.Read(byte1, 0, (int)wresp.ContentLength)
stream.Close()
wresp.Close()
String sOut = encoding.GetString(byte1)
Console.WriteLine(sOut)
catch(WebException exWeb)
throw exWeb
catch (Exception e)
throw e
and I keep on gettin
{"The remote server returned an error: (500) Internal Server Error."
I am behind a firewall and have added port 8081 to the ports alowing TCP traffic in both directions
Cheers
I am trying to POST to a URL using the HTTPWebRequest object
straight forward
ASCIIEncoding encoding = new ASCIIEncoding()
string s = "username=66"
HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create("http://url:8081/sendSMS/SendSMS"

wreq.Method="POST"
// Set the content type of the data being posted
wreq.ContentType = "application/x-www-form-urlencoded";//"Text/XML"
byte[] byte1 = encoding.GetBytes(s)
wreq.ContentLength = byte1.Length
try{Stream stream = wreq.GetRequestStream()
stream.Write(byte1, 0, byte1.Length)
stream.Close()
WebResponse wresp = wreq.GetResponse()
byte1 = new Byte[wresp.ContentLength]
stream = wresp.GetResponseStream()
stream.Read(byte1, 0, (int)wresp.ContentLength)
stream.Close()
wresp.Close()
String sOut = encoding.GetString(byte1)
Console.WriteLine(sOut)
catch(WebException exWeb)
throw exWeb
catch (Exception e)
throw e
and I keep on gettin
{"The remote server returned an error: (500) Internal Server Error."
I am behind a firewall and have added port 8081 to the ports alowing TCP traffic in both directions
Cheers