PxPlus User Forum

Twitter Twitter Twitter

Author Topic: How to send a POST request using *BROWSER  (Read 1537 times)

cwellis67

  • Member
  • **
  • Posts: 9
    • View Profile
How to send a POST request using *BROWSER
« on: January 23, 2024, 12:55:36 PM »
Is there a tutorial or other information that can explain how to send a POST request using *BROWSER instead of the old shell.explorer.2 COM object? Before, when we called the NAVIGATE2 method, we passed in the post data along with the URL, but it doesn't seem like the *BROWSER object is seeing it now.

Mike King

  • Diamond Member
  • *****
  • Posts: 3818
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: How to send a POST request using *BROWSER
« Reply #1 on: January 23, 2024, 02:52:15 PM »
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

cwellis67

  • Member
  • **
  • Posts: 9
    • View Profile
Re: How to send a POST request using *BROWSER
« Reply #2 on: January 23, 2024, 04:11:13 PM »
So does that mean that while the old shell.explorer.2 COM object allowed us to send data to the web page (like user name and log in), the *BROWSER object can only display the web page and we have to send a web/request to communicate with it?

Mike King

  • Diamond Member
  • *****
  • Posts: 3818
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: How to send a POST request using *BROWSER
« Reply #3 on: January 23, 2024, 04:26:15 PM »
What are you actually trying to do?

*browser will allow you to display a web page from which the user could fill in controls and have the data POSTed to a server with the results being a new/updated web page.  There's a lot of other options here if you want to learn JavaScript and use things like AJAX.

You asked how to POST data, which is what *plus/web/request will allow you do.  Basically you create the data to be POSTed then using this routine you can forward the data to a URL and receive a response for processing.

 
« Last Edit: January 23, 2024, 05:07:00 PM by Mike King »
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

cwellis67

  • Member
  • **
  • Posts: 9
    • View Profile
Re: How to send a POST request using *BROWSER
« Reply #4 on: January 24, 2024, 12:26:35 PM »
Hey Mike,
Thanks for responding. I am currently trying to replace our use of shell.explorer.2 with *browser, and in particular, the line of our code where we use this:

x'navigate2(post_url$,flags,frame$,*postobj,headerinfo$) ! Start navigation with passed url

In that line, the POST data is sent with the navigate2() method. With *browser, it doesn't seem we can send POST data with the navigate2 method, and I just wanted to confirm that, or find out what I am doing wrong.

Devon Austen

  • Administrator
  • Diamond Member
  • *****
  • Posts: 384
  • Don’t Panic
    • View Profile
    • PVX Plus Technologies
Re: How to send a POST request using *BROWSER
« Reply #5 on: January 24, 2024, 12:45:44 PM »
Hi Chris,

No you aren't doing it wrong it is just that *browser does not currently support doing a POST.

As Mike suggested you can use *plus/web/request to do the post and get the response. Then if there is a page to display use *browser to display it. If you are not displaying anything *plus/web/request will be much faster since it doesn't have to load a whole browser to do the request it just does it directly via TCP/IP requests.
Principal Software Engineer for PVX Plus Technologies LTD.

Mike King

  • Diamond Member
  • *****
  • Posts: 3818
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: How to send a POST request using *BROWSER
« Reply #6 on: January 24, 2024, 01:24:12 PM »
In your logic where you issue the Navigate2 call, what is happening with the resultant response?

If you simply want to submit the posted data and are planning on throwing away the response or at least not displaying it the *plus/web/request is likely all you need.

However, if you are expecting a response of a web page you wish to display so the user can continue then you likely will need to create some JavaScript and HTML to load into *browser so that it can post the data.

Alternatively you might be able to blend these so you make the request using *plus/web/request then pass the resultant response to *browser for it to display.  This may work however if the response includes things such as cookies it likely will fail.

Now all that being said, if the data is basically form fields it may be possible to simply include them in the URL.  Often applications won't care if data comes from the URL (i.e. http: //somesite.com?field=xxx&field2=yyy) or from posted data.  So if you are simply emulating the user entering fields on a form, try appending the desired data on the URL you pass to navigate2.

« Last Edit: January 24, 2024, 03:20:39 PM by Mike King »
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com