Navigate with post data

Dear Xojo users,
I need to navigate from Xojo to a URL, much like “GotoURL” is working, but I would like to navigate to that page while setting Request Headers and Request Body, like they are set when creating “URLConnection” to send (sync) some data.
Is there a way to do that?

Thank you.

No. Just like you can’t send a manual POST from the browser without dev tools.

The reason POST/PUT/DELETE/etc. are not idompotent, so having a way to tell the browser to send potentially dangerous requests is a bad thing. So everything you put into the address field is a GET request, with potentially an OPTIONS sprinkled in. GET requests are not supposed to change data, so this is generally safe.

Even if the request were to respond with a 301 or 302 that you try to capture with URLConnection, that wouldn’t work since URLConnection follows redirects.

1 Like

You could have your xojo app write an html file with embedded javascript that constructs and executes your POST action, then use System.GotoURL to open it.

But at that point you may as well do it with URLConnection.

I am already doing something very simmilar. Creating a full script that even creates elements of a dummy page, and I am able to navigate using data. However, the big problems are headers. I just can not set requests headers, which in some cases are essencial.

You managed to confuse me. Xojo is a dev tool.

urlconnection have request headers
https://documentation.xojo.com/api/networking/urlconnection.html

Creating a full script that even creates elements of a dummy page, and I am able to navigate using data. However, the big problems are headers. I just can not set requests headers, which in some cases are essencial.

maybe u can use fetch api in javascript at client side?

The key bit was “from the browser.” So I mean the browser’s dev tools.

1 Like

You should contact the content owner and ask them how they would like you to interact with their website. If you are allowed to do the things you are trying to do, I’m sure they will be happy to help.

1 Like

URL connection is not taking you to a page, but sending data to that page. I want to navigate there WITH the data.

It sounds like either the target webpage/site is not set up as a proper external API, or you are trying to spoof the source of the POST data for some reason.

What is it exactly you are trying to accomplish?

1 Like

so basically you will start by a local/temporary html “website” viewed in browser to navigate then via post
to a target page. similar to a input form submit.

I need to navigate from Xojo to a URL

do you speak about a Xojo Desktop or Xojo Web-Application?

Your idea is most commonly used by malicious actors and there are technologies in place to prevent it from working.

I point you back to Thom’s post about why what OP wants to do is a security concern. Navigate with post data - #2 by Thom_McGrath

Until OP explains what they actually want to do functionally, what they have described cannot be done. If there is no API to interact with the website, the content owner may not want you to be automating their website.

OP needs to seek permission from the content owner first.

2 Likes

I am trying to secure accessing to my web page, and I am actually trying to create an emulator to do that. I don’t want just anyone to be able to access a certain web application I have created. The idea is that visitor to have pre-agreed credentials that I can check. The best is to put credentials in headers / body structure, rather than as URL parameters with long strings. But, from what I see, I must create emulator in another programming language.

Don’t make offensive assumptions. Show some respect.

You asked us to do something that is impossible instead of asking us how to achieve what you really wanted to do. All I did was respond with facts and basic suggestions, I made no offensive assumptions.

If you are the content owner, I’m sure there’s a process that could be recommended; but if you’re going to react like that when asked about your actual goal, I will abstain from providing any further insight.

Just setup a VPN that the site is only accessible from.

Impossible for Xojo. Yet can be done in JavaScript. http - JavaScript: How can I POST an arbitrary request body to a server? - Stack Overflow
I am the content owner, I want more security as it is sensitive data. I CAN NOT DEVELOP just by guessing. I need an emulator that will be “my customer accessing to me”. And I DO THANK YOU for not participating more.

Suggestion is OK but not in this case.
I will just use JavaScript if there is not such a thing in Xojo.

XmlHttpRequest is essentially just a URLConnection. If that solves your problem in JavaScript, then URLConnection solves it in Xojo.

You said you wanted a version of GoToURL that does a POST. That is not the same thing. But maybe it was a bad problem description. That’s why we ask for goals.

Still, it sounds like a VPN would be a much better solution. Don’t try to roll your own security. People smarter than you and I have already solved this problem.

1 Like

That would be ideal, but any call to page where I can carry a JSON and navigate toward it would do the trick. It can be done in most of the programming languages. Just can’t find if Xojo is offering that. Regardless, I will test in another fashion (if debug, then act if there is a header…). Thank you for your time.