Recent

Author Topic: [SOLVED]httpRequest, can't get process website form data  (Read 1429 times)

Matt723

  • New Member
  • *
  • Posts: 20
[SOLVED]httpRequest, can't get process website form data
« on: January 22, 2020, 12:08:01 pm »
Hi Everyone

I'm having issues with httpRequest.

This is the code:
 
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2.   begin
  3.     httpRequest(process('http://www.tigerfan.com/login', 'form(//form[@id = "pageLogin"], {"login": "aaaExample1", "password": "Example1"})')); // This work perfectly
  4.   end;
  5.      
  6. procedure TForm1.Button2Click(Sender: TObject);
  7.   begin
  8.     httpRequest(process('http://www.tigerfan.com/threads/hello-im-new.172489/add-reply', 'form(//form[@id = "ThreadReply"], {"message": "test"})')); // But this doesn't work
  9.   end;                          

It throws the following error:
https://imgur.com/a/SPD6Hrh

This is what the page looks like:
https://imgur.com/a/PHtv7YR

This is its source of the webpage:
https://pastebin.com/93ihAHYr

Am I posting it to the wrong form (ThreadReply)? Does it matter if the box that the message is inputted into (shown in the second Imgur link) is not active?

The login details in the code are real, so you can give the code a try.

Thank you for any advice,
Matthew
« Last Edit: January 22, 2020, 11:15:51 pm by Matt723 »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: httpRequest, can't get process website form data
« Reply #1 on: January 22, 2020, 12:26:37 pm »
It's not really an error as such. The HTTP status code of 405 means that the particular method you used is not allowed by the server for the target resource.

Maybe it thinks you're not logged in? Is there a cookie you should be providing?

Matt723

  • New Member
  • *
  • Posts: 20
Re: httpRequest, can't get process website form data
« Reply #2 on: January 22, 2020, 03:33:07 pm »
Thank you for your reply trev. If you log in to a website on your browser, you can use the website's features without logging in again (until you log out). Is this not the case with httpRequest? When I initiate Button2Click to post the reply, the homepage shows that I'm logged in. If this is not the case, do you know how I can tell the website that I am logged in when I post the reply?

Thanks for your time.

BeniBela

  • Hero Member
  • *****
  • Posts: 905
    • homepage
Re: httpRequest, can't get process website form data
« Reply #3 on: January 22, 2020, 10:13:37 pm »

This is what the page looks like:
https://imgur.com/a/PHtv7YR


That is not what the page looks like

When you open http://www.tigerfan.com/threads/hello-im-new.172489/add-reply in the browser, you also get an error message


You can only open the page with a button click on "more options", which needs another form() call to convert the button to a http post request.


Or you can directly post from http://www.tigerfan.com/threads/hello-im-new.172489/ with the QuickReply form


Matt723

  • New Member
  • *
  • Posts: 20
Re: httpRequest, can't get process website form data
« Reply #4 on: January 22, 2020, 11:11:45 pm »
Ah, the QuickReply form works perfectly, and I understand now why it didn't work before, thank you BeniBela.

 

TinyPortal © 2005-2018