wunderground - makeWebRequest does not work (error -400)

Former Member
Former Member
Hello,
I’m trying to make an forecast app based on wunderground data. It works fine in the simulator but when I run it on fenix 5x it returns INVALID_HTTP_BODY_IN_NETWORK_RESPONSE error (-400). I have no idea where could be a problem... Any help will be much appreciated :)
Here is a portion of code:

var options = {
:method => Comm.HTTP_REQUEST_METHOD_GET,
:headers => {
"Content-Type" => Comm.REQUEST_CONTENT_TYPE_JSON
},
:responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_JSON
};

var params = {
};

var url = "api.wunderground.com/.../myAPIkey/forecast/q/pws:KKSOLATH93.json";

Comm.makeWebRequest(url, params, options, method(:onReceive));
  • It looks to me like you're doing it right, but your post is very similar to this one. If I were you, I'd try to intercept the network traffic and get a peek at the request/response when using the watch. You can use a tool like ngrok to redirect from a public address to your local machine, then use tcptunnel to tunnel back out to weather underground while displaying the traffic. Then you'd update your widget to point at the ngrok.io address and run the program.

    Ideally, you'd capture the traffic for both the simulator and the device, and you'd paste it here for someone to have a look at.

    Travis
  • Also, if it is available, I'd switch from using http to https.
  • One things with the wu "forecast" requests is it returns a lot of data. What watch are you running on? watch-app or a widget? (a number of strings with the forecast in Statute and metric and more...)

    I've given up trying to do a forecast except on CIQ 2.x devices and then with a watch-app. and not a widget. (the f5x has a max of 58k for a widget, so less than 1.x devices, so you may want to try a watch-app which has more memory available)

    "Conditions" works fine on even 1.x devices in a widget though. The call looks fine to me.. I switched to https some time ago so that is available with WU.

    What type of phone are you using? Android or iOS?

    I have a WU widget in the app store that does conditions and astronomy calls, if you want to get that a try to check out your environment. (click on my app store link) It runs on a f5x with 3.30 FW, and the current Android version of GCM.
  • Former Member
    Former Member over 7 years ago
    Travis and jim_m_58, thank you for your suggestions. I’ve got f5x and android phone and I tried to develop a widget (I thought there is more than 58k of memory available on f5x, in that case I have no chance :) ). I had sometimes problems with lot of forecast data even in simulator so I tried both conditions and astronomy response but with the same result on f5x (even if I tried a very simple widget it returns -400). I hope I’ll be able to setup a proxy in next few days and check the traffic.

    I have a WU widget in the app store that does conditions and astronomy calls, if you want to get that a try to check out your environment. (click on my app store link) It runs on a f5x with 3.30 FW, and the current Android version of GCM.


    Yes, I have it installed for a while and it works really great, so if I’ll give up with my own attempt (I’m trying to accomplish it because it took me a lot of time so far :) ) it wouldn’t be any disaster :)
    Thanks
    r
  • Former Member
    Former Member over 7 years ago
    Just for information: I had not enough time and patience to test the network traffic thoroughly, but I tried to run widget in f5x occasionally and about a week or two ago it started to work (without any obvious cause). So it works fine now, maybe implementation of background process would be nice :)