Is makeJsonRequest implemented?

Is makeJsonRequest implemented in the simulator?

using Toybox.Communications as Com;
//.....

Com.makeJsonRequest(
"http://localhost:8080",
params, opts, cb);


But I only get Symbol Not Found Error.

BTW, it would be incredibly useful if the compiler/vm/runtime could tell me: which symbol was not found? Same thing for type errors, that sort of things. Most runtime error messages aren't super helpful.

Thanks!
  • Yeah, I ran into the same error this evening with makeJsonRequest(). :(
  • In your manifest file did you put a permissions tag for Communcations?

    <iq:permissions>
    <iq:uses-permission id="Communications"/>
    </iq:permissions>


    This is the first thing that comes to my mind when you get the symbol not found error for makeJsonRequest(). We've added a permissions error and it'll be in the next release, so in the future it'll give a better error when you forget to register a module that requires permissions. We'll also be working on giving the symbol that wasn't found in the error message.
  • I'm operating from memory here, but I was using the Comm example as a basis for my testing, and I verified last night that the necessary entry is in manifest.xml. I also had a check to verify that the Communications module was available...

    if (Toybox has :Communications) {
    Comm.makeJsonRequest(url, params, options, member(:onJsonData));
    }
    else {
    _code = -1;
    }


    If the has operator is working as expected, I'd expect _code = -1 to be executed instead of the call to makeJsonRequest().

    I'll verify that what I said above is actually what is happening when I get home this evening.
  • Ok, thanks! Sorry I missed the permission.

    It's working for me now, except the callback doesn't seem to follow the API documentation: The first parameter it receives is the json data dictionary, and I'm not sure there is any other param expected for the callback function (i.e. no responseCode).
    Basically the doc says: responseCallback(responseCode, data);
    But I see something like: responseCallback(data);
  • Well... it's almost working.
    The following Json doc is loaded fine:
    {
    "Foo": "Bar"
    }


    Also working fine:
    {
    "Foo": {"Bar": "Baz"}
    }


    But crashing the simulator:
    {
    "Foo": ["Bar"]
    }
  • Okay, I managed to get it to work as well. My mistake. I had written Comm.makeJsonRequest(...), but I had brought the package in under the name Com. Now that I've got that worked out, I'm seeing the same behavior you are.

    Travis
  • Former Member
    Former Member over 10 years ago
    The unexpected behavior you guys are experiencing here is mostly due to implementation errors on our part at this time. Fixing issues with the JSON request API is something we hope to have taken care of in the next preview.