Using HandleURL in the same proyect

If I have the following in my 2021 v2 WEB project:

An App
With two events: HandleURL & Opening
And one or more methods

& One web page with a button.

Is it possible to make my calls to HandleURL on this web page?

Like this sample:


Var ShowMe As String
ShowMe = Session.Header("Host") + "/Sample"

Var Myconex As URLConnection
Var content As String = Myconex.SendSync("GET",ShowMe, 30)
ContentArea.Text = content

My goal is to test locally before sending it to the cloud server. So you don’t need to compile and run the listening API first and then using Get or Post in other applications.

Var ShowMe, content As String
Var Myconex As URLConnection
Myconex = New URLConnection

ShowMe = "http://"+Session.Header("Host") + "/Sample"
content = Myconex.SendSync("GET",ShowMe,30)
ContentArea.Text = content

It works for running and testing locally.

Before deployment, you can delete the content so that only the App object with the HandleURL event and an empty web page remains.

With this, you can add and test using “Run” in the project. It is without having to create another project to send a request to an App in the cloud.

While I see your original goal was to avoid additional apps, software like Paw and Postman make building REST APIs with Xojo significantly easier. You don’t need to deploy remotely to use these tools and can test locally running debug builds.

I feel like this method of testing described in this thread would reach it’s technical ceiling really fast as you add additional endpoints to your API. I would recommend you look at the tools I suggested, you merely have to change the url to your local debug run url.

2 Likes

You’re right, Tim.

I just wanted to have an API solution that works only with XOJO without using third-party tools.

I am going to evaluate the tools you mention. Especially POSTMAN, which I have already seen other users recommend.

Do you have any suggestions you can give me before checking these solutions?

I personally use Paw. It does what I need and was reasonably priced. I discovered Paw before discovering Postman, and I’ve grown to like it. I don’t have experience with Postman, so it would be unfair to make any comments on it.

It may be worth starting a “Paw or Postman?” thread to see if other folks have opinions to weigh in.

Thanks.

The important thing is to understand and use these tools, to understand when it is necessary to use them in development.