I’m trying to understand this page: URLConnection — Xojo documentation but not able to work out how to use it.

I want to make the equivalent of a ‘curl’ call to a webserver, but don’t understand how to break the curl command up correctly to use the TCPSocket. The command is this:

curl --location --request POST "https://localhost/scan/binary" --header "Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation" --data-binary "@/home/user/Documents/File.docx" --insecure

Can anyone advise how to do this using native code rather than a plug-in (if possible)?

1 Like

if you drop that UrlConnection into a window add a button and in the click event
something like this

Var f as FolderItem = SpecialFolder.Documents.Child("File.docx")
MyConnection.RequestHeader("Content-Type") = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
Var content As String
content = MyConnection.SendSync("POST", "https://localhost/scan/binary", f, 30)
Var status As Integer = MyConnection.HTTPStatusCode


Note that SendSync will lock the main thread.
Better to use Send

1 Like

thanks, will give this all a try