How to send a POST request using *BROWSER

Started by cwellis67, January 23, 2024, 12:55:36 PM

Previous topic - Next topic

cwellis67

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

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

cwellis67

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

#3
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.

 
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

cwellis67

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

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

#6
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.

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com