Connecting to remote server using makeJsonRequest()

Former Member
Former Member
Can someone please explain how makeJsonRequest() works, as I can't seem to get a response from a remote host. I am using the Comm example provided as a base and simply adding the line:
Comm.makeJsonRequest(URL+"/rest/auth/login", {}, {}, method(:onLogin));
to the menu button for Ackbar, so that it is called every time that button is clicked.

The url is definitely working in a browser, and the comm example also working, however no response or error occurs. The onLogin function is implemented as follows:
function onLogin(data){
System.println("Login Request Response");
}


Thanks.
  • Have you added the communications permission to your manifest?

    Also, making a network request is not supported in data fields for example, as well as watch faces if I recall correctly. It's somewhere in the doc, but I'm om my phone now, hard to verify.
  • Former Member
    Former Member over 10 years ago
    Yeah, permissions are set, otherwise I don't think the mailbox communications would work either, and this is running on a square watch.
  • Former Member
    Former Member over 10 years ago
    I am having the same issue as the original poster. I also have permissions setup in the manifest file but do not receive any callback indicating the network request was completed. Looking at older posts it appears that some people have had success making these calls. I just do not see anything in the docs that tells if any setup is needed to simulate the Garmin Connect bridge for making internet requests.
  • May be a stupid thing to check, but is the response from the server valid json?
    Can you see if the server got the request in the logs?
    Have you tried to use a proxy to see the request/response go through?
  • Former Member
    Former Member over 10 years ago
    I have not spent time messing with a proxy, but am able to load a json file on a local web server running on my machine. Hopefully someone from Garmin can chime in on the availability of remote calls in the simulator or a time frame when they will be supported.
  • I've had some success, but I'm away from my code right now. I'll post an example later.
  • Sadly, I can't get anything to work reliably. I get simulator crashes at the worst, and bogus data at best. I ran through tcptunnel and the requests are going out and coming back, so the problem is somewhere in ConnectIQ. When I experimented with this originally, I found that some json data would cause problems. It was mentioned in this thread.

    Travis
  • Former Member
    Former Member over 10 years ago
    So I seemed to have got a connection now. Not sure how since everything is pretty much the same. The data is coming through, although I'm also getting crashes when reading arrays as previously mentioned.