WebHook Help - GET

Wisdom trust / @ScruffR

I need some help with regards to a webhook GET request which is working, however I’m not getting the data out that I need.

I have a webhook linked to a sensor data from my garden; the response, when called is

["45"]

Obviously I’d like to get out the 45, as a number (45% as a soil moisture level guide), however the above, from what I understand, is an array of characters? 45 can change, and so I need to monitor the variable, otherwise would just make a constant! When I try the webhook link

void soil_guide(const char *event, const char *data) {
  soilguide_data = atof(data);
}

I get nothing out (0 printed on the webserver page I log into). I imagine it is related to the characters / symbols included in the response.

I think I’m missing something with regards to the various characters in the array. I understand that data is a 6 field {string?) array which I would think is “[”, " " ", “4”, “5”, " " ", “]”. 6 elements.

Can I use moustache to remove the everything except the two digit number? - I haven’t done anything fancy in my webhook, just standard.

Or how could I get the two digit 45 into an integer variable to use within my code?

Just FYI that I have been able to get other webhook responses to work, however the response was a 2 digit number response, which seems to be easy to parse through atof and into the code.

Have spent a couple hours on this, so feel as though I might be at a dead end! Thanks.

Neal.

Resolved before wisdom required… and some learning done on my side.

Ended up having success with @rickkas7’s Mustache Tester… fixed it on the webhook side to simplify the data being sent to the Photon (makes sense really).

Thanks all. Data flowing. Photon’s happy.

Neal.

1 Like