Hello all,
I'm trying to do flagging in the craigslist.org, firstly it works, but when I
used the WebProxy, it gave me this error:
The remote server returned an error: (400) Bad Request
This is my code :
HttpWebRequest myWebRequest = WebRequest.Crea te("
http://flag.craigslist .org/?flagCode=28&po stingID=8845894 38") as
HttpWebRequest;
WebProxy myProxy=new WebProxy();
// Print the Proxy Url to the console.
Console.WriteLi ne("\nThe actual default Proxy settings are {0}",myProxy.
Address);
try
{
string proxyAddress;
proxyAddress = "http://143.215.129.117 :3128";
if (proxyAddress.L ength 0)
{
// Create a new Uri object.
Uri newUri = new Uri(proxyAddres s);
// Associate the newUri object to 'myProxy' object so that new
myProxy settings can be set.
myProxy.Address = newUri;
myWebRequest.Pr oxy = myProxy;//when i comment this, it works
}
Console.WriteLi ne("\nThe Address of the new Proxy settings are {0}",
myProxy.Address );
HttpWebResponse myWebResponse = (HttpWebRespons e)myWebRequest. GetResponse
();
Console.WriteLi ne(new StreamReader(my WebResponse.Get ResponseStream( )).
ReadToEnd());
}
catch(Exception ex)
{
Console.WriteLi ne(ex.Message);
}
Anybody can help me?
Thank you!!
Jed
I'm trying to do flagging in the craigslist.org, firstly it works, but when I
used the WebProxy, it gave me this error:
The remote server returned an error: (400) Bad Request
This is my code :
HttpWebRequest myWebRequest = WebRequest.Crea te("
http://flag.craigslist .org/?flagCode=28&po stingID=8845894 38") as
HttpWebRequest;
WebProxy myProxy=new WebProxy();
// Print the Proxy Url to the console.
Console.WriteLi ne("\nThe actual default Proxy settings are {0}",myProxy.
Address);
try
{
string proxyAddress;
proxyAddress = "http://143.215.129.117 :3128";
if (proxyAddress.L ength 0)
{
// Create a new Uri object.
Uri newUri = new Uri(proxyAddres s);
// Associate the newUri object to 'myProxy' object so that new
myProxy settings can be set.
myProxy.Address = newUri;
myWebRequest.Pr oxy = myProxy;//when i comment this, it works
}
Console.WriteLi ne("\nThe Address of the new Proxy settings are {0}",
myProxy.Address );
HttpWebResponse myWebResponse = (HttpWebRespons e)myWebRequest. GetResponse
();
Console.WriteLi ne(new StreamReader(my WebResponse.Get ResponseStream( )).
ReadToEnd());
}
catch(Exception ex)
{
Console.WriteLi ne(ex.Message);
}
Anybody can help me?
Thank you!!
Jed
Comment