Errors returned from Web requests

Former Member
Former Member
Hi there,

I am trying to fix an app that uses the Communications module and gets some json data from a website. I've had a user say that they get an error -300 on their Fenix5X, but I am not sure if this just that the API needed a boot. They then reported getting error -400. I'm now having a look at the widget and I get error -400 on my watch (VivoActive) for this site,
The errors mean as follows: NETWORK_REQUEST_TIMED_OUT = -300 INVALID_HTTP_BODY_IN_NETWORK_RESPONSE = -400
If I access the API the data seems to be formed fine - here is an example of the data that I get. The app also seems to work OK in the simulator which reckoned 26.8/58kB
{"status":[{"now":1507746978061}],"bgs":[{"sgv":"120","trend":5,"direction":"FortyFiveDown","datetime":1507746187255,"filtered":135104,"unfiltered":129088,"noise":1,"bgdelta":-5,"iob":"1.01","bwp":"-1.01","bwpo":-7487}],"cals":[{"slope":849.377297763804,"intercept":26812.094971367154,"scale":1}]} Has anything changed with how you have to consume json data and manipulate it in the last few months?

Thanks,

R
  • In the sim, what's the peak memory (file->view memory)? what changed since you starting having problems? New GCM or something? Is it with iOS, Android, or both?

    maybe post your makeWebRequest
  • Former Member
    Former Member
    Hi Jim,

    Thanks for the reply.

    The peak memory is 29.2kB so nothing excessive. I think that only time has passed since I started having problems, which comes with it new GCM apps, and watch updates I guess. My phone is Android running Nougat and my watch is a VA with Connect iQ 1.4.2. The other person's is a Fenix5X but I don't know what phone. The slightly odd thing is that I have an app that is analogous to my widget and that is working for the site, but the widget isn't working.
    This is how I do my makeWebRequest:

    sys.println ("setting the URL from application properties");
    url = "https://" + apprun.getProperty("sitename") + apprun.getProperty("hostdomain") + "/pebble";
    **** quite a lot of other code****
    if (currentsettings.phoneConnected) {
    globalText = "Loading\n....";

    comms.makeWebRequest(url ,{"units"=>propunits} ,{"Content-Type"=>comms.REQUEST_CONTENT_TYPE_JSON} ,method(:onReceive));
    sys.println ("Receiving");
    }
    else {
    globalText = "Phone not\nconnected";
    }
    // then I have an onReceive method that does this:
    function onReceive(responseCode, data)
    {

    globalText = "data here";
    Ui.requestUpdate();
    sys.println ("Receiving data");
    if( responseCode == 200 )
    {

    if (data["bgs"].size()!=0) {

    gotData = true;
    // even more code in the what to do if the responseCode is 200
    }
    else{
    sys.println("No BG data");
    globalText = "No BG data";
    }
    }
    else if (responseCode == -2){
    globalText = "No internet\nconnection";
    }
    else {
    globalText = "Website\nError: " + responseCode.toString();
    }

    // ///////////////// end of code sample - what I then do is display the globalText on the watch face, so normal people get the error returned from the web request.

    R.