First, thanks for the previous help provided on using Web hooks. I have my code functioning and now want to clean up some of the processes to provide the web hook body from firmware instead of the integration form.
I currently have a ‘POST’ web hook with the following custom body:
{
"location": {
"address": {
"line1": "351 N Main",
"line2": "none",
"city": "Nolos",
"state": "OH",
"zip": "44122"
}
},
"services": {
"fire": false,
"police": false,
"medical": false,
"other": true
},
"name": "Nivlek Trahreg",
"phone": "14444470569",
"pin": "12234"
}
How I want to use a web hook where I can provide the data from firmware. So I tried this:
{
"location": {
"address": {
"line1": "{{{line1}}}",
"line2": "{{{line2}}}",
"city": "{{{city}}}",
"state": "{{{state}}}",
"zip": "{{{zip}}}"
}
},
"services": {
"fire": "{{{fire}}}",
"police": "{{{police}}}",
"medical": "{{{medical}}}",
"other": "{{{other}}}
},
"name": "{{{name}}}",
"phone": "{{{phone}}}",
"pin": "{{{pin}}}
}
The code I used is
testData = String::format( "{ \"line1\":\"%s\",\"line2\":\"%s\",\"city\":\"%s\",\"state\":\"%s\",\"zip\":\"%s\",\"fire\":\"%s\",\"police\":\"%s\",\"medical\":\"%s\",\"other\":\"%s\,\"name\":\"%s\",\"phone\":\"%s\",\"pin\":\"%s\"}", line1.c_str(), line2.c_str(), city.c_str(), state.c_str(), zip.c_str(), (fire ? "true" : "false"), (police ? "true" : "false"), (medical ? "true" : "false"), (other ? "true" : "false"), name.c_str(), phone.c_str(), pin.c_str());
Particle.publish("498 testData", testData);
delay(10000);
Particle.publish("nla_alarm_create", testData, PRIVATE);
delay(60000);
The testdata looks good but the POST returns a 400 error.
What am I missing?
Thanks.
5310