Unable to render proper output from webhook

I am trying to create a webhook that will get an array of integers from a single field (field2) of a Thingspeak channel. I need to minimize the output so as not to overrun the webhook limit. The output I'm trying to produce would be like this:

what I get so far is this:
2024-01-31 14:12:11 -0600,1297,HEAT,235,61.6,18.2,26.1,68.0_67.4,52.2_51.0,
2024-01-31 15:12:26 -0600,1298,HEAT,420,62.0,32.8,46.2,70.1_67.7,44.9_43.0,
2024-01-31 17:28:45 -0600,1299,HEAT,399,61.7,31.4,44.8,70.3_68.3,48.2_45.3,
2024-01-31 20:03:46 -0600,1300,HEAT,410,61.9,31.3,44.7,70.5_68.6,47.4_45.3,
2024-01-31 21:31:04 -0600,1301,HEAT,410,61.6,31.2,44.8,69.9_67.5,48.3_44.7,
2024-01-31 23:48:44 -0600,1302,HEAT,410,62.3,30.6,43.7,7

Below is the custom template I'm using although I've tried many variations. I think I need to use a responseTemplate but everything I've tried so far seems to kill the output. Would anyone have some insight into my problem?
Thank you,
"name": "Get_HVAC_RT_History",
"event": "Get_HVAC_RT_History",
"deviceID": "999999999999999",
"responseTopic": "",
"errorResponseTopic": "",
"url": "https://api.thingspeak.com/channels/0000000/feeds.csv?api_key=MYREADKEY&minutes=1440&offset=-6",
"requestType": "GET",
"noDefaults": true,
"rejectUnauthorized": true,
"responseTemplate": ""

You can't process and return a subset of the data when using the csv feed in Thinkspeak.

One option is to switch to feeds.json and use mustache variables to parse and return a subset of the output.

1 Like

Thank you Rick. I tried the json before but I guess the moustache was not correct in the response template. Now I can get the first instance of field2 with {{feeds.0.field2}} but I don't know the moustache expression to get all the values and I can't seem to find out how to do it. Is there a tutorial somewhere that tells how?
The formatted JSON looks like this:


You need to put something in field8. The number 0 would work. The problem is that the feeds JSON is not valid JSON, so it won't be able to be parsed.

The technique is explained and there's a tester which is way faster than trying things randomly in the JSON page.

The response template will be similar to this. It iterates the feeds key array for objects, and extracts the field2 object into a comma-separated list.


I tried your example and it worked perfectly. I'll also check out the tester link you set for better understanding in future projects. I did not have to insert a zero in field8 but it parsed completely anyway.
Thank You,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.