Error from Webhook - Unexpected Token

I am just started a new project to measure solar insolation based on the climate monitor by Bruan Krohn on hackster.io.using a Particle Photon.

It is gathering data but I get nothing past the Webhook. Adding a debug block there shows:

{ uri: ‘/v1/webhooks’,
method: ‘POST’,
json:
{ event: ‘insolation’,
url: ‘https://triggers.losant.com/webhooks/deleted’,
deviceid: undefined,
requestType: ‘POST’,
mydevices: true,
json: { value1: ‘{{l}}’ } },
headers: { Authorization: ‘Bearer deleted’ }
}

I cannot find any unpaired ‘}’. Anyone have any ideas?

David

Opps, the error did not post up there, it is:

Error
Unexpected token }

Looks like there’s an extra } in there?

I see that, but the code to create the webhook looks balanced:

{
“event”: “insolation”,
“url”: “https://triggers.losant.com/webhooks/deleted”,
“requestType”: “POST”,
“json”: {“value1”: “{{l}}” },
“mydevices”: true
}

So where is that extra one coming from?

I create it with:

particle webhook create structure-webhook.json

I jumped into your workflow to take a closer look. The error is caused by the data field coming from Particle:

"data": "{ \"l\": 2686.0, }"

There’s an extra comma after 2686.0, which makes this invalid JSON. The error you’re getting in the workflow is coming from the function node trying to JSON.parse this string.

Good catch! Thanks. I corrected that and now there are no errors, but still nothing in the device log. Funny, it says not connected but in the debug I see the data. So maybe its still not Json enough? Also tried a time series graph but nothing there, and would not expected it if it is not logging data.

Found it! another glitch in the tutorial not matching the current code. Now its graphing!