Recent

Author Topic: [SOLVED]httpRequest, can't get process website form data  (Read 1040 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: 932
  • 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?
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

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: 753
    • 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