Webhook Template issue

I am trying to set up a mustache template for a webhook. The issue seems to be that the data returned from the external API starts with an array:


With a tester, I was able to get this to work fine…


Which was outputting:


However, this causes an error on the Particle Webhook.

I can use {{0.ParameterName}}:{{0.Data}} and that works fine. But sometimes there are more or fewer values.

Am I doing something wrong?

Hi @jed,

Just to find out more details, could you elaborate on the commands used to input / perform the webhook? Please share your curl or API commands. Thanks.

Particle Technical Support

It appears that it is not possible to parse a top-level array that is returned in the message body of a webhook.

This syntax


is correct. However, I believe it fails to work because in addition to the variables in the webhook response, the built-in variables like SPARK_EVENT_NAME are also available, and they are mixed together using Object.assign(). This means the top-level is no longer an array, it’s an object, with a weird mix of key/value pairs and array elements. But since it’s no longer an actual array, it can’t be iterated using {{#}}.

I wasn’t able to think of a reasonable work-around to this.

I figured it was something like that. Shoot.

It appears that it’s valid to start a JSON string with square brackets (and some other tokens besides curly brackets). Should this be reported as a bug?