ThingSpeak Webhook Integration Not Working

I've been attempting to get my webhook sending two pieces of data to ThingSpeak to work for a while now, but keep getting back error status 400 (which is said to be due to poor/incorrect syntax). Trouble is that I can't seem to find the cause of this tripping up.

My firmware (specifically the portion publishing):


The json being formatted here looks fine by my eyes.
Ex: {"temperature":22.6,"humidity":44.39}

My integration (nothing below Custom Body is filled out, other than "Enforce SSL" set to Yes):


For reference, my full custom body is (with api_key omitted for obvious reasons):
{{"api_key":"", "field1":{{temperature}}, "field2":{{humidity}} }}

Event Viewer:

Any ideas or help would be greatly appreciated. Thank you!

Hi, I looked at your info and nothing jumped at me.

I usually troubleshoot these issues by sending the webhook to a service like this:

you can change the destination url of your webhook to what pipedream gives you:

then you can get all the info from the request (body and headers):

best

2 Likes

Not sure if this helps, but I had to put 3 curly brackets around the variable names to make it work:

My body code:

{
"api_key": "XXXXXXXXXXXX",
"field1": "{{{wind_speed}}}",
"field2": "{{{temp_f}}}",
"field3": "{{{pressure}}}",
"field4": "{{{humidity}}}",
"field5": "{{{rainfall}}}",
"field6": "{{{percent_charge}}}",
"field7": "{{{wind_direction}}}"
}

2 Likes

It's unclear why the triple curly brackets worked in this case; they prevent HTML special character from being escaped, but I wouldn't have expected that to make a difference for your data.

However, at least it's working now, and triple curly brackets are almost always the right thing to use when generating JSON, so I'd go with that.