makeJsonRequest() with long Mongolab-URL: Error Code 404

I have a problem with Comm.makeJsonRequest(). Everything works fine with a test URL (simulator und watch), with the original URL it does not work (error code: 404). However, the original URL works like a charm with a browser.

Test URL:
http://echo.jsontest.com/date/143233300900/svg/81/direction/Flat

Original URL (the API key I have omitted here):
api.mongolab.com/.../entries, 'SGV':1, 'direction':1, 'date':1}&apiKey=my API Key

What's the problem and what can I do?

Thank you for your suggestions,
Andreas
  • What device and FW version? Search the forums as I recall seeing something about http vs https under some cases.
  • Error 404 on device (vivoactive) and simulator (every device). Http and https make no difference.
  • Former Member
    Former Member over 10 years ago
    As jim has eluded, https will not work in the simulator. If you are still unable to to reach the original url from the device; how are you building the request?
  • Shark - i did remember that https worked one place but not the other, but didn't recall the detail!

    It should probably be noted in the "Simulator bugs" thread started last week..
  • Thank you, SHARKBAIT_AU. You are right, that's the case. The simulator sucks.

    On the watch I get with original URL (Mongolab) the Error Code 0. That means: I reach the Url but something went wrong ...
    Depends the unknow Error 0 on the following result (first row of an array)?

    [ { "date" : 1432333009000 , "sgv" : 150 , "direction" : "Flat"} ]

    Thanks for helping!

    (I try to make a widget which shows the last bloodglucose reading from dexcom/nightscout.)
  • Former Member
    Former Member over 10 years ago
    I suspect it's how you are building your request. I haven't sent nested variables yet, but I expect it's something like....

    var apiKey = "yourApiKey";
    var server = "api.mongolab.com/.../entries";
    var options = {"l"=>"1","s"=>{"date"=>"-1"},"f"=>{"_id"=>"0","SVG"=>"1","direction"=>"1","date=>"1"},"apiKey"=>apiKey};
    Comm.makeJsonRequest(server, options, null, method(:onReceive));
  • Former Member
    Former Member over 10 years ago
    As far as I can tell you can't send nested variables. Sending...
    var value2 = {"key3"=>"value3"};
    var options = {"key1"=>"value1","key2"=>value2};

    the server receives...
    { key1: 'value1', key2: '{key3=>value3}' }

    So unless you can create your own server response handler, I think you're out of luck.
  • Thank you again. I don't send nested variables, I send only options to manipulate the server response.

    The response that I get is the first row of a sort of table (not array) containing all bloodglucose readings:

    [ { "date" : 1432333009000 , "sgv" : 150 , "direction" : "Flat"} { "date" : 1432333008940 , "sgv" : 148 , "direction" : "Flat"} ... ]
  • On the watch I get with original URL (Mongolab) the Error Code 0.


    I see this (error code 0) under a couple of conditions on the vivoactive itself (and there could be more and sometimes there is a more specific error instead).
    1) If while performing the makeJsonrequest(), there is a loss of bluetooth (you get out of range). As a side note, I always use a check of "phoneConnected" before doing the makeJsonreqest(), as you can get various errors if you don't.

    2). While the phone is in my pocket and BT is fine, I walk out of wifi range of my home network, and it switches to the cell network for data in the middle of the makeJsonRequest() call.

    In other words, I've seen it when the format of the call is correct, but there is something in the connection itself that has a problem (or is different.