0

HTTP calls - client vs server context

I am wondering if there is a way to force http calls exclusively from the client context. I have tried to use

do as client

but that is automaticly changed to do as server

The reason it needs to be local is because the script is collecting unsecure sensor data from the local network. These sensor endpoints are not reachable from the Ninox server.

Calling Services in Server Context
Sometimes, it is desirable to not execute HTTP requests in the context of the client but in the context of the Ninox Cloud server. This is especially required when calling endpoints that are not secured by SSL — since the Ninox native apps for Mac, iPhone and iPad are not able to query such insecure endpoints.

 

The script seems to work in the local context from the native apps for Mac, iPhone and iPad with insecure endpoints.

I have not been able to get my http scripts working on the the web based app.

 

let r := this;
let p := (create 'Sensor Data');
let response := http("GET", "http://" + 'IP address' + "/co2");
if response.error then
alert(text(response.error));
delete p
else
p.('CO2 PPM' := number(response.result))
end;
let response := http("GET", "http://" + 'IP address' + "/temp");
if response.error then
alert(text(response.error));
delete p
else
p.(Temp := number(response.result))
end;
let response := http("GET", "http://" + 'IP address' + "/hum");
if response.error then
alert(text(response.error));
delete p
else
p.(Humidity := number(response.result))
end;
p.(Table1 := r)

4 replies

null
    • Thad_Robertson
    • 5 yrs ago
    • Reported - view

    I have the same problem. Calls to http("GET", url,...) work fine in the native apps but not on the web. I get this error: {"error":"Request failed: error - "} 

    • blackie
    • 5 yrs ago
    • Reported - view

    I am able to get secure http URLs to work in the native app and on the web, but only secure URLs work on the web.

    • Frank_Bohmer
    • 5 yrs ago
    • Reported - view

    To call an unsecured or not CORS-aware endpoint:

    let response := do as server http(...) end

    do as server will still run in client context, when working with local or iCloud databases (since there's no server). Thus, some endpoints are not reachable from local or iCloud databases becouse of Apple's sandbox rules.

    • blackie
    • 5 yrs ago
    • Reported - view

    “CORS-aware endpoint”

    ok, I think I am being to better understand. The local or iCloud DB can make unsecured requests as long as they are in the originating domain. In my case in the 192.168.1.x subnet.

     

    It seems like when I try to make the same request using the web client, it is executed in the context of the server and fails, because the server does not have access to the 192.168.1 x network.

     

    When using the web client, is it possible to make requests in the context of the web client instead of the server, so there will be access to the local 192.168.1.x network?

Content aside

  • 5 yrs agoLast active
  • 4Replies
  • 2743Views