I know this is probably something simple I’m missing but I’ve been scouring the docs and forum for the last day to no avail.
My web hook:
{
"eventName": "post_data",
"url": "https://api.parse.com/1/classes/SensorData",
"requestType": "POST",
"headers": {
"X-Parse-Application-Id":"xxx",
"X-Parse-REST-API-Key":"xxx",
"Content-Type":"application/json"
},
"json": {
"ph" : "{{ph}}",
"temperature" : "{{temperature}}"
},
"mydevices": true
}
And my firmware, customized from some of the readily available examples and tutorials. Using OneWire for my DS18b20, Wire for an Atlas Scientific pH circuit:
char ph_data[48]; // 48 byte char array to hold data from ph
float celsius, fahrenheit; // float to hold and convert data from temp
// Publish Data
sprintf(resultStr, "%s %s", ph_data, String(fahrenheit).c_str());
Spark.publish("post_data", resultStr, 60, PRIVATE);
//Spark.publish("post_data", "{ \"ph\": \"ph_data\", \"temperature\": \"fahrenheit\" }", 60, PRIVATE);
With the above code, Parse creates the object and inputs blank data into the ph and temperature columns. Event Data on both Parse and Particle Dashboard shows current ph_data and fahrenheit as a single string (resultStr)
. Particle Dashboard shows hook-sent data as undefined.
If I switch to the commented out Spark.publish
based on the Webhook Custom Template docs, Parse inputs plain text ph_data and fahrenheit, not the values they represent.
Also, if I change
"json": {
"ph" : "{{ph}}",
"temperature" : "{{temperature}}"
},
to
"json": {
"ph" : "{{ph_data}}",
"temperature" : "{{fahrenheit}}"
},
it inputs blank data to Parse, regardless of which Spark.publish
I use.