Note that there are some explanatory texts on larger screens.

plurals
  1. POSequence of HttpWebRequest
    text
    copied!<p>I am currently in the process of automating a web interface for administrating users of an FTP.</p> <p>I am trying to do this with HttpWebRequest, i have one call that logs me on the site and the second call is supose to add a new user for the FTP access.</p> <p>I have tried my two urls in the browser and they work, they end up creating a user.</p> <pre><code>string login = "https://www.ftpsite.net/./panel/index.php?txvUsername=myaccount&amp;txvPassword=myPassword&amp;submitButton=Login"; </code></pre> <p>this gets me logged in when i enter it in the browser address bar.</p> <p>the second call to create a user is as follows.</p> <pre><code>string createUser = "https://www.ftpSite.net/panel/ftpsites/updatelogin?login_id=&amp;login=toto123&amp;realname=realnametoto&amp;homedir=root&amp;passwd=superpassword11&amp;expdate=01-01-2100&amp;neverExpire=on&amp;quota_value=0&amp;quota_unit=GB&amp;group_id=0&amp;status=on&amp;ftp=on&amp;filelist=on&amp;ftp_download=on&amp;http=on&amp;web_filelist=on&amp;web_download=on&amp;email="; </code></pre> <p>This creates a user when i enter it in the browser's address bar if it follows the one that logs us in.</p> <p>My problem is that i am trying to do this using HttpWebRequest and without success. I can get myself logged in but when i try to create the user it seems to return a "bad" error code saying i have created too many users already which isnt the case since i can create more after that call. Here is the code i use with HtttpRequest</p> <pre><code> _datCookie = new CookieContainer(); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(login); httpWebRequest.Method = "POST"; httpWebRequest.CookieContainer = _datCookie; WebResponse response = httpWebRequest.GetResponse(); referer = response.ResponseUri.AbsoluteUri; Stream requestStream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(requestStream); _datCookie = httpWebRequest.CookieContainer; response.Close(); httpWebRequest = (HttpWebRequest)WebRequest.Create(createUser); httpWebRequest.CookieContainer = _datCookie; httpWebRequest.Referer = referer; httpWebRequest.Method = "POST"; response = httpWebRequest.GetResponse(); requestStream = response.GetResponseStream(); streamReader = new StreamReader(requestStream); webBrowser.DocumentText = streamReader.ReadToEnd(); response.Close(); </code></pre> <p>What i caught and tried to imitate without success <a href="http://i.imgur.com/UtIbz.jpg" rel="nofollow">here</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload