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.Create("
http://flag.craigslist.org/?flagCode=28&postingID=884589438") as
HttpWebRequest;
WebProxy myProxy=new WebProxy();
// Print the Proxy Url to the console.
Console.WriteLine("\nThe actual default Proxy settings are {0}",myProxy.
Address);
try
{
string proxyAddress;
proxyAddress = "http://143.215.129.117:3128";
if (proxyAddress.Length 0)
{
// Create a new Uri object.
Uri newUri = new Uri(proxyAddress);
// Associate the newUri object to 'myProxy' object so that new
myProxy settings can be set.
myProxy.Address = newUri;
myWebRequest.Proxy = myProxy;//when i comment this, it works
}
Console.WriteLine("\nThe Address of the new Proxy settings are {0}",
myProxy.Address);
HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse
();
Console.WriteLine(new StreamReader(myWebResponse.GetResponseStream()).
ReadToEnd());
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Anybody can help me?
Thank you!!
Jed