Webhhooks: Custom JSON Script still adds adds 'default attributes' and not all json is being sent

@joearkay, can you post your updated webhook so we can see where it stands now?

@peekay123 this is a local issue I think. The webhook works fine when I write the json manually. I have done a Serial.println() on the json that includes concatenated variables.

This string:

String publishString = "{\"ty\":" + type + ",\"u\":" + uuid + ",\"n\":" + name + ",\"sy\":" + sysID + ",\"sh\":" + sID + ",\"d\":" + subType + ",\"c\":" + cType + ",\"l\":" + location + ",\"ti\":" + tStamp + "}"; 

with these variables:

String type = "\"Alarm\"";
String uuid;
String name = "\"testAlert\"";
String sysID = "\"testLocation\"";
String sID = "\"testShId\"";
String subType = "\"not\"";
String cType = "\"testAlarm\"";
String location = "\"Global\"";
String tStamp = "\"00-00-0000\""; //need to change this later
 String buff(key.returnUUID()); //converting uuid to a string 
 uuid = "\"" + buff + "\"";

Only yields this on 'Serial.println(publishString)'

{"ty":"Alarm","u":"d7a692e9-bec5-41af-bb2a-1afe5026ff4d","n":"testAlert","sy":"t
estLocation","sh":

which is the same as what I get to the Particle cloud, which means it’s an issue with this string concatenation.

@joearkay, you may want to ditch the String stuff and use a char array along with sprintf() to build the string. :wink:

@peekay123 I feared as much :grin: I hate char arrays, I’ll give that a go, thanks!

1 Like

That’s a bit like: “I’ll rather stick with my tricycle because I hate motor bikes :wink:
Once you got the hang of the latter, they are way more fun :sunglasses:

But char arrays are also safer :smile:

1 Like

I know, I know :grin:

Thanks for the help gents! I’ll give it a go today

1 Like