Hi again
Following on from my attempt at using webhooks with Lambdas (which I don’t believe will work) I have created an array of timestamped data in my electron and published it.
I have some additional questions.
- Why do the square brakcets and quotes disappear from my array data.
- what is the maximum length of the data field, so I know how many records I can post.
I’ll explan below,
I want to post this data using a webhook
{
"key": "blah-blah",
"tag": "SomeUniqueNameOrID",
"units": "m³/hr",
"description": "Description of the source if available",
"values": [
[ "2016-07-25T12:00:00Z", 0.0 ],
[ "2016-07-25T13:00:00Z", 0.1 ],
[ "2016-07-25T14:00:00Z", 0.2 ],
[ "2016-07-25T15:00:00Z", 0.3 ],
[ "2016-07-25T16:00:00Z", 0.4 ],
[ "2016-07-25T17:00:00Z", 0.5 ],
[ "2016-07-25T18:00:00Z", 0.6 ],
[ "2016-07-25T19:00:00Z", 0.7 ],
[ "2016-07-25T20:00:00Z", 0.8 ],
[ "2016-07-25T21:00:00Z", 0.9 ],
[ "2016-07-25T22:00:00Z", 1.0 ],
[ "2016-07-25T23:00:00Z", 1.1 ],
[ "2016-07-26T00:00:00Z", 1.2 ],
[ "2016-07-26T11:00:00Z", 1.3 ]
]
}
here is my web hook.
{
“event”: “multi_post”,
“url”: “https://requestb.in/19hvwv61”,
“requestType”: “POST”,
“noDefaults”: “Yes”,
“body”:"{“key”: “blah-blah”, “tag”: “{{t}}”, “units”: “pulses”, “description”: “Meter {{t}}”,“values”:"{{{v}}}"}"
}
here is the publish from the electron (via a printf on the serial port)
log JSON is -> {"t":"test_meter","v":[["2017-06-12T03:54:50Z",0],["2017-06-12T03:54:51Z",0],["2017-06-12T03:54:52Z",0],["2017-06-12T03:54:53Z",0],["2017-06-12T03:06:33Z",0],["2017-06-12T03:06:34Z",0],["2017-06-12T03:06:35Z",0]]}
here is the event from the particle console
{
“name”: “multi_post”,
“data”: “{“t”:“test_meter”,“v”:[[“2017-06-12T03:54:50Z”,0],[“2017-06-12T03:54:51Z”,0],[“2017-06-12T03:54:52Z”,0],[“2017-06-12T03:54:53Z”,0],[“2017-06-12T03:06:33Z”,0],[“2017-06-12T03:06:34Z”,0],[“2017-06-12T03:06:35Z”,0]]}”,
“ttl”: 60,
“published_at”: “2017-06-12T03:54:54.843Z”,
“coreid”: “12234545432523453245” <—I edited this not sure if it is secret or not
}
and here is the post at Requestb.in
{"key": "blah-blah", "tag": "test_meter", "units": "pulses", "description": "Meter test_meter","values":"2017-06-12T03:54:50Z,0,2017-06-12T03:54:51Z,0,2017-06-12T03:54:52Z,0,2017-06-12T03:54:53Z,0,2017-06-12T03:06:33Z,0,2017-06-12T03:06:34Z,0,2017-06-12T03:06:35Z,0"}
As you can see it is really close to being correct but the square brackets and the quotes around the time have all disappeared. I did add an extra set of curly brackets to make a triple set around the array and also a set of quotes around the whole array, the extra quotes appear but are not wanted.
Any ideas?
Thanks
Marshall