EDIT: I solved my own issue using Custom Body webhook. Posted my approach below.
So I should start by saying that what I’m trying to achieve may not be possible or even advisable.
Basically I am utilising webhooks to write data to Firebase via it’s REST API.
My initial webhook’s json looked like this (and worked perfectly):
"json": {
"tmp": "{{tmp}}",
"rpm": "{{rpm}}",
"volt": "{{volt}}",
"sig": "{{sig}}",
"ts": "{{PARTICLE_PUBLISHED_AT}}"
},
With my publish data in this format:
sprintf(str, "{\"tmp\":%.2f,\"rpm\":%d,\"volt\":%.1f,\"sig\":%d}",
temp,
speed,
volt,
signal);
This loads data into database as per the following:
What I would LIKE to achieve in future versions however, is a more dynamic push event where I can loop through a map of available data types with a key:value pair and publish all of these.
Something like the following pseudo-code:
for(available data) {
addToPubStr(data.key : data.val);
}
publish(pubStr);
I played around with moustache functionality in the webhook but couldn’t get an output like I was desiring.
I’m imagining a publishString like {"key1": "value1", "key2": "value2", etc}
being parsed in the same manner as the original webhook.
Any tips, advice or alternatives would be greatly appreciated!
Kind Regards,
Alex