shehab Posted August 16, 2011 Report Share Posted August 16, 2011 when i try to connect with utorrent it only show results for html replying methods below is the code i'm using------------------------------------------------------------------------------------------------------------------------------WebClient client = new WebClient() { Credentials = new NetworkCredential("username", "password") };StreamReader Reader = new StreamReader(client.OpenRead("http://localhost:" + "port" + "/gui/"));-------------------------------------------------------------------------------------------------------------------------------it replies with bad request for JSON based replying methods for example http://[iP]:[PORT]/gui/?list=1any help Link to comment Share on other sites More sharing options...
shehab Posted August 17, 2011 Author Report Share Posted August 17, 2011 There were two problems in my code1. I didn't use the token from (http://localhost:port/gui/token.html)2.the above request returned a cookie which i didn't save, so you have to keep the cookie with you.Classes.CookieAwareWebClient client = new Classes.CookieAwareWebClient() { Credentials = new NetworkCredential("username", "password") };StreamReader Reader = new StreamReader(client.OpenRead("http://localhost:" + "port" + "/gui/token.html"));string token = HtmlRemoval.StripTagsRegexCompiled(Reader.ReadToEnd());MessageBox.Show(token);Reader = new StreamReader(client.OpenRead("http://localhost:" + "port" + "/gui/?list=1&token=" + token));MessageBox.Show(Reader.ReadToEnd());about the cookie aware web client it' an overridden class of web client you can find in the following link (http://stackoverflow.com/questions/1777221/c-using-cookiecontainer-with-webclient-class) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.