I know I’m missing something obvious, but I’m trying to bring an app forward from RealStudio. This (slightly redacted) code runs fine in RealStudio and returns an xml response containing a session ID. In Xojo, it times out. Any hints?
// http is an HTTPSocket dragged onto the window
dim s as string
dim d as new dictionary
d.value("username")= "abc"
d.value("password")= "xyz"
http.SetFormData(d)
http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
s= http.post("www.example.com/api/v1/user/login", 30)
I created a throwaway user so I could post actual code:
dim s as string
dim d as new dictionary
d.value("username")= "test"
d.value("password")= "test"
http.SetFormData(d)
http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
s= http.post("www.telios.com/drupal/api/v1/user/login", 30)
You say in the comment in your original code “// http is an HTTPSocket dragged onto the window”
I might be losing my mind, but I don’t find an HTTPSocket control that can be dragged into a window in the latest version of Xojo.
I have always instantiated them in code.
[quote=333706:@Tim Hare]I know I’m missing something obvious, but I’m trying to bring an app forward from RealStudio. This (slightly redacted) code runs fine in RealStudio and returns an xml response containing a session ID. In Xojo, it times out. Any hints?
[/quote]
First off open real studio and see if the old code still works there
That will rule out any back end changes the site has made as the cause
[quote=333711:@Jared Feder]You say in the comment in your original code “// http is an HTTPSocket dragged onto the window”
I might be losing my mind, but I don’t find an HTTPSocket control that can be dragged into a window in the latest version of Xojo.
I have always instantiated them in code.
[quote=333712:@Norman Palardy]First off open real studio and see if the old code still works there
[/quote]
It does. That’s the first thing I did.
Interestingly, it does work in Xojo if I change it to an HTTPSecureSocket with Secure=False. So I have a workaround. The next challenge will be to use the new framework.
[quote=333715:@Tim Hare]It does. That’s the first thing I did.
Interestingly, it does work in Xojo if I change it to an HTTPSecureSocket with Secure=False. So I have a workaround. The next challenge will be to use the new framework.[/quote]
I have run into that same issue with webservices, but only on Windows.
The good thing is that your workaround will work on both Windows and macOS, even though it isn’t necessary for macOS builds.
OK, so I attempted to use the new framework. I put another socket on the window named http2 with super Xojo.Net.HTTPSocket. This code is based on the example on http://developer.xojo.com/xojo-net-httpsocket. It returns a 401 status code, which I think is authentication error. What am I missing?
using xojo.core
using xojo.data
dim d as new Dictionary
dim json as text
dim data as MemoryBlock
d.value("username")= "test"
d.value("password")= "test"
json= generateJSON(d)
data= TextEncoding.UTF8.ConvertTextToData(json)
http2.SetRequestContent(data, "application/x-www-form-urlencoded")
http2.Send("POST", "http://www.telios.com/drupal/api/v1/user/login")