I’m trying to use webhooks to post data to some IoT dashboards like initialstate
and ubidots
via json.
With InitialState, I need to post to their REST api using a json array. Ubidot doesn’t require this, but it would be great as that way I can post two different variables in one webhook definition (say temperature and humidity) which may become more important if I hit against the webhook limits.
InitialState: http://docs.initialstateeventsapi.apiary.io/#reference/event-data/events/send-events
Ubidot bulk: http://ubidots.com/docs/api/v1_6/collections/post_variables_id_values.html#post-api-v1-6-collections-variables-id-values
I can create a webhook with the json as an array, but it looks like the request going to the API is a pre-defined dictionary combined with user’s defined values (tempF and humidity in my case) based off tests against requestbin.
I’m surprised that requests to 3rd parties were constructed this way as it contains debugging info that most likely won’t be used by them. In any case, is there a way to make web-hooks work with my use-case?
##Attempt to defined webhook request as Json array
{
"eventName": "tempF",
"url": "http://https://groker.initialstate.com/api/events",
"requestType": "POST",
"json": [{
"key": "{{SPARK_CORE_ID}}_tempF",
"value": "{{tempF}}"
},
{
"key": "{{SPARK_CORE_ID}}_humidity",
"value": "{{humidity}}"
}],
"mydevices": true
}
Expected request body:
[
{
"key": "My_ID_tempF",
"value": 76
},
{
"key": "My_ID_humidity",
"value": 65
}
]
Actual request body (sanitized):
{"0":{"key":"MY_CORE_ID_tempF","value":"75"},"1":{"key":"MY_CORE_ID_humidity","value":"59"},"event":"tempF","data":"{ \"tempF\": \"75\", \"humidity\": \"59\", \"epoch\": \"-1787744360\" }","published_at":"2015-06-02T07:49:34.186Z","coreid":"MY_CORE_ID"}