Weather sample apllication "failed to load: Error: -202"

Former Member
Former Member
I am trying to use the "Weather" sample application in the simulator. Instead of the city and tempersture I always receive a HTTP 202 error/status code after starting a FIT simulation. I must be overlooking the obvious?

Windows 10
connectiq-sdk-win-1.2.1
Eclipse IDE for Java Developers - Version: Mars.1 Release (4.5.1)
  • Seems Open Weather started requiring an "API KEY" a few months back, and the sample doesn't include one (too many folks would just use that one instead of getting their own).

    I understand that what you have to go to Open Weather's site, get one, and add it to the makeJsonRequest();

    http://openweathermap.org/appid
  • Former Member
    Former Member over 9 years ago
    I forgot to mention in my opening post, but I did try that without success. I registered and received an AppID key, which I added to the JSON request. So my code in the onPosition handler now looks like the code below (note that I will reset the AppID in time). To verify the AppID is correct I also did a succesvol request using my browser with this AppID.

    var latLon = info.position.toDegrees();
    var appid = "65d02aa573a25990d3f7da25c1bffed6";

    Sys.println(latLon[0].toString());
    Sys.println(latLon[1].toString());

    Comm.makeJsonRequest("api.openweathermap.org/.../weather",
    {"lat"=>latLon[0].toFloat(), "lon"=>latLon[1].toFloat(), "appid"=>appid}, {}, method(:onReceive));

    notify.invoke("Loading\nWeather");
  • Not sure then - but you may want to obscure your API Key in your post, as others may start using it!

    Could it be that once you get a key, it takes a day to get activated or something?

    What I do in a similar case is just use a browser to enter the request, and insure it works there, and when it does, figure out what's going on with the makeJsonRequest();

    Oh. in your request, based on the version of the SDK you have, there is a bug where you have {} - use "{:method=>Comm.HTTP_REQUEST_METHOD_GET, :headers=>{}}" instead. But what I saw was a runtime error in the simulator without it.

    so the end of the request would look like this:

    ...,{:method=>Comm.HTTP_REQUEST_METHOD_GET, :headers=>{}}, method(:onReceive));
  • Former Member
    Former Member over 9 years ago
    Thank you very much! Adding "{:method=>Comm.HTTP_REQUEST_METHOD_GET, :headers=>{}}" to the makeJsonRequest did the trick.

    I resetted the AppID so the one in this post is no longer working.
  • All the stuff I posted does is provied the defaults, but the defaults are currently broken.

    Also, I guess you haven't been testing in the simulator, or it would have been caught with an odd error displayed.

    You can test this in the simulator. All you have to do is select "Simulation" and then "Fit Data", then "Simulate Data". That provides the GPS location you need to run. You get the current weather near Garmin in Kansas, BTW! (You can also playback a .fit file of your own, as long as it was recorded with GPS)
  • Former Member
    Former Member over 9 years ago
    In fact I did all the testing in the simulator. The Weather app was compiling and running without any runtime errors. The only error was the HTTP 202 code. Also good to know that it is the defaults that are broken.
  • The bug that broke the makeJsonRequest() defaults has been fixed for the next SKD release, and we'll have an updated Weather Sample, too. It's not actually going to be a weather sample anymore, but a more generic JSON request sample that uses an API we're more confident will not require an API key in the future. :)