Communications.makeJsonRequest API on vivoactive device not working

Former Member
Former Member
Hi,

I am trying to use Communications.makeJsonRequest to make a HTTP GET request on a vivoactive device. the Device is connected via BLE to a iPhone running the Garmin Mobile Connect app. The request works on Simulator, but didn't work on vivoactive device. Does anyone know how to get this to work ? thanks
  • Do you know what kind of response you're getting back when you make the request? That should help point to what might be causing you trouble.
  • Former Member
    Former Member over 10 years ago
    I am experiencing the same problem. I was able to get it to work every once and awhile, but mostly it just never comes back. I set up a proxy on my computer for my iPhone so I am able to see that the json call comes back just fine with a 200, but either it doesn't get the data back to the watch or some issue is happening that makes it so the display doesn't refresh.
  • So you're not getting to the callback on the MakeJsonRequest() call? You can use Sys.println() with a pre-created file /garmin/apps/<appname>.txt on your device if you think it's a display thing...

    How much data do you expect to get back? If the data has the wrong format, it might not hit the callback with a 200, but with an error instead.

    Could it be an issue with your proxy? it should be device>phone>webserver and back first and make sure that works.

    I can't recall not getting a callback on the makeJsonRequest() call under any error condition.
  • Assuming that your callback isn't being invoked, using a proxy or a network monitor is likely to be the best option for debugging.
  • Former Member
    Former Member over 10 years ago
    I'll try outputting to the .txt file when I get home this evening and see what I get back. Thanks for the tip!
  • I'll try outputting to the .txt file when I get home this evening and see what I get back. Thanks for the tip!


    Also, on your callback, insure that onUpdate() will get called even on error conditions, with some indication of the error (Ui.requestUpdate() )

    In real use, it's not odd to get an error on the makeJsonRequest() call, even if the request is fine, for things like timeouts, a glitch on the server, etc..

    I'll see UNKNOWN_ERROR every once in a while for no particular reason, and then try the request again and it works fine.

    Oh, one othet thing - on a real device, things take much longer than in the sim for makeJsonRequest() calls, and the timeout can make it look like your not getting the callback when you just aren't waiting long enough.
  • Okay, I was able to get the .txt thing to work and I see that it's returned a -300 error. I see that is a NETWORK_REQUEST_TIMED_OUT error, but I'm not really sure why since I do see a response via the proxy. Oh well, I guess I'll just try something else.



    You got a timeout, so even the proxy did see a response, but didn't pass it on in time... Nothing came back to the device. (a time out)

    That would explain why it works sometimes and not others. Sometimes it comes back in time, and sometimes it doesn't.

    This sounds like an issue with your proxy.
  • Former Member
    Former Member over 10 years ago
    It didn't work at all without the proxy either. The json document isn't huge, but it's not small either. I'm going to try with a small json document and see if that works.
  • Former Member
    Former Member over 10 years ago
    Well, the json response was too long. It looks like if the json response is more than couple hundred characters in length it never comes back.
  • Well, the json response was too long. It looks like if the json response is more than couple hundred characters in length it never comes back.


    Not true. I have functioning stuff that gets a response more than a few hundred bytes long (well over 1000 in fact). I think it's your proxy. Maybe it only passed on part of the response but never finished it?

    Why do you have a proxy in the middle? Try removing it from the chain...