0

How can I establish a connection with Jsoup in order to fill & send a form?

The website looks similar to this:

          <form action="the.form" method="post"
                enctype="application/x-www-form-urlencoded"
                name="start_form"
                autocomplete="off">
             <input type="hidden" value="8F5EB4CD93CAB4E093EF7C1C733791FC" name="session" />
             <input type="text" value="" name="number" />
             <div class="right">
                <input type="submit" name="submit" value="Submit" />
             </div>
          </form>

What I tried:

    Document doc = Jsoup.connect(DUMMY_URL).data("number", "123456789", "session", 
"6F80A198EC4B46B4848897A33ACAC3E8").header("Content-Type","application/x-www-form-urlencoded").userAgent("Mozilla").post();

Result:

Exception in thread "main" java.io.IOException: 501 error loading URL https://www.theurl.com
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:414)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:391)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:157)
    at org.jsoup.helper.HttpConnection.post(HttpConnection.java:152)
    at Test.main(Test.java:17)

What is wrong here?

membersound
  • 81,582
  • 193
  • 585
  • 1,120
  • possible duplicate of [How to submit text via forms using JSoup](http://stackoverflow.com/questions/6644168/how-to-submit-text-via-forms-using-jsoup) – jamesmortensen May 16 '12 at 01:49

1 Answers1

0

I have already answered this on THIS thread.

If you have any further doubts, just ask.

Community
  • 1
  • 1