Struggling with webhook response

Hi! And sorry if my problem is very obvious but I just can’t figure it out!

I am playing with webhooks in order to get weather data. When I check on the dashboard, I see webhook response in two beautiful chunks. Apparently untouched except some escaping:

"<current><city id=\"2643743\" name=\"London\"><coord lon=\"-0.13\" lat=\"51.51\"></coord><country>GB</country><sun rise=\"2015-08-24T05:00:39\" set=\"2015-08-24T19:03:50\"></sun></city><temperature value=\"289.36\" min=\"287.55\" max=\"290.37\" unit=\"kelvin\"></temperature><humidity value=\"88\" unit=\"%\"></humidity><pressure value=\"996\" unit=\"hPa\"></pressure><wind><speed value=\"3.6\" name=\"Gentle Breeze\"></speed><gusts></gusts><direction value=\"20\" code=\"NNE\" name=\"North-northeast\"></direction></wind><clouds value=\"40\" name=\"sca"

and

"ttered clouds\"></clouds><visibility></visibility><precipitation value=\"2.03\" mode=\"rain\" unit=\"1h\"></precipitation><weather number=\"521\" value=\"proximity shower rain\" icon=\"09d\"></weather><lastupdate value=\"2015-08-24T14:47:08\"></lastupdate></current>\n"

But when I Serial.println the data I get in the webhook listener, I get weird trunked piece of data.

Any idea? Here’s the firmware I use: http://pastebin.com/dqCNLapd
Thx!

Try this Tutorial.

2 Likes

@LukeUSMC 's tutorial may be helpful, particularly if you get a JSON response.

Your response looks like HTML so I’d also check this link for an example of what to do:

https://docs.particle.io/guide/tools-and-features/webhooks/

Post your webhook as well. What data do you want?

@LukeUSMC thanks for that tutorial, very helpful. I see two differences with what you’ve done:

  • Your response is in Json
  • You used response template in your webhook configuration.

I am going to try that and see if it works better than getting all the response and parse it “manually” (:

Here’s my webook (from particle webhook list):

1.) Hook ID 55d78fce6a877be930694c83 is watching for "get_weather"
        and posting to: http://api.openweathermap.org/data/2.5/weather?q=london&mode=xml&APPID=XXXXXX
        created at 2015-08-21T20:53:34.895Z

Thanks @LukeUSMC, it works like a charm when using JSON + responsetemplate.

Though, I still don’t understand why I could get the full response otherwise.

Anyway, thanks again!

1 Like

Glad it helped! There’s a message size limit for webhooks so it was being broken up at the limit…I think at least. I prefer the response template way since it saves me from culling data I don’t want.

1 Like