Little help with URLConnection

Hi…

I’m getting a strange error here:

Var myURL As New URLConnection
Var response As String
response = myURL.Send(“GET”, “https://opencep.com/v1/12941040”, 30)

Error: There is more than one method with this name but this does not match any of the available signatures.

Why?

and if i use instead:
response = myURL.SendSync(“GET”, “https://opencep.com/v1/12941040” , 30)
the response is an error 404

but if i put the URL on browser, it works…

You definitely need SendSync if you want the response right away, but URLConnection is not the same as a browser. You should check with the owner of the website and see what the restrictions are

2 Likes

Check the documentation, there is no ‘Send’ that gives a String so you can’t do response = myURL.Send(... but there is a signature for SendSync to give a String.

2 Likes

To pile on to what others have said here, when you use .Send you are invoking an asynchronous “GET” and need to get and process the result in the ContentReceived event.

.SendSync will lock up your application until it either completes the query or the timeout elapses.

If you’re getting error 404 on something that works with the browser, you may be missing something in a header. The User-Agent is a common one. Or perhaps there are prerequisite cookies. You’ll need to reverse-engineer your browser result in the browser’s developer tools to see what it’s sending that your URLConnection is missing.