Error from Webhook - Unexpected Token

#1

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

0 Likes

#2

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

Error
Unexpected token }

0 Likes

#3

Looks like there’s an extra } in there?

0 Likes

#4

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?

0 Likes

#5

I create it with:

particle webhook create structure-webhook.json

0 Likes

#6

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.

0 Likes

#7

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.

0 Likes

#8

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

0 Likes