Errors with URLConnection Example in Documentation

Here:

the example snipped is (are):

Var content As MemoryBlock
content = MyConnection.SendSync("GET", "http://127.0.0.1:8080/GetData", 30)

I suspect something was missing in the documentation.

FYI: Gemini returns the same kind of code…
content = URLConnection.SendSync("GET", imageURL, timeoutInSeconds)

What must I do ?

Mention what errors are you getting.
Provide a sample project with description of what you are trying to do.
Check the examples that Xojo offers, this is the code in one of them:

Var content As String = WebConnection.SendSync("GET", URLField.Text, 30)
ContentArea.Text = content

This is the error:

Providing a desktop example will be useless: the code comes from the Documentation “as is”. It is in a button. the project holds only that button… not even saved !

and…

the documentation for URLConnection (top of page):

Class

URLConnection

REST


Description

Used to send and receive data using the HTTP 1.1+ protocol.

Properties

When I came back to the Documentation, the page (or my hand on the Mouse moves) was displaying the previous entry/entries and I saw:

Var connection As New URLConnection

And that seems to be the solution/answer / the missing line.

Not all snippets of code in the documentation can be copied “as is”.

That is why I mentioned the examples that Xojo offers, so you can see the parts that you are missing.

I’m glad that you found the line of code that helped you.

1 Like