0

I've googled my arse off on this one.

The form includes this:

<input name="Terms" data-required="true" type="checkbox" class="validated">

And I desperatley try to handle it like this:

WebRequest req = WebRequest.Create(link);
        string postData = "data-required=false";

        byte[] send = Encoding.Default.GetBytes(postData);
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = send.Length;

        Stream sout = req.GetRequestStream();
        sout.Write(send, 0, send.Length);
        sout.Flush();
        sout.Close();

        WebResponse res = req.GetResponse();
        StreamReader sr = new StreamReader(res.GetResponseStream());
        string returnvalue = sr.ReadToEnd();
        Console.WriteLine(returnvalue);

Note that it works to set "data-required" to false and submit in the browser manually.

Any suggestions?

OHMR
  • 393
  • 6
  • 16

1 Answers1

0

data-required is HTML5 tag that marks field as required, it has nothing to do with sending values to server. If you want to send POST request indicating that checkbox is checked, you have to send this in request body:

Terms=on

Terms is the name of field and on is value indicating that checkbox is checked

Novakov
  • 3,055
  • 1
  • 16
  • 32