jeudi 2 mars 2017

Unable to send POST data of a form

i have a problem with a Web Post Form. I have download the page, I extrapolated the two required values (form_build_id and form_token), but once sent the POST the server does not receive anything.

Excluded errors:

  • Wrong link (can download the page).
  • Incorrect extrapolated data (verified).
  • Wrong string myParameters (verified).
  • I have tested the Form manually and it work fine.

Some idea? There I slam my head for two days!

using (WebClientEx wc = new WebClientEx())
        {
            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            string HTMLPage = wc.DownloadString(CREAT_TICKET_URL);

            string form_build_id    = SearchValue(HTMLPage, "<input type=\"hidden\" name=\"form_build_id\"", "value=\"", "\"  />");
            string form_token       = SearchValue(HTMLPage, "<input type=\"hidden\" name=\"form_token\"", "value=\"", "\"  />");

            string myParameters = "macchina=" + cmacExtID + "&utente=" + custExtID + "&oggetto=" + Title + "&body=" + Note + "&op=Conferma&form_build_id=" + form_build_id + "&form_token=" + form_token + "&form_id=app_form_new_ticket";

            string HtmlResult = wc.UploadString(CREAT_TICKET_URL, myParameters);
        }

Note: WebClientEx class inherits WebClient. I used this approach to other forms such as login and work.

The final question is: if this approach is wrong, what is the best way to do this sequence of operations "download the page, fair extrapolate, send post form"?




Aucun commentaire:

Enregistrer un commentaire