API tests ok, however doesn't output to variable

Hello,

I am trying to pull specific data e.g. field2 data from a Thingspeak URL.

the output is listed below

The api to connect to this is

GET https://api.thingspeak.com/channels/1531630/fields/2.json?&results=1

Authorization has been removed.
I get the result below in the API.

{
“channel”: {
“id”: 1531630,
“name”: “HydropiMonitor”,
“latitude”: “0.0”,
“longitude”: “0.0”,
“field1”: “AIR ('C)”,
“field2”: “Pool ('C)”,
“field3”: “Solar ('C)”,
“created_at”: “2021-10-10T00:56:01Z”,
“updated_at”: “2021-10-10T19:38:32Z”,
“last_entry_id”: 97501
},
“feeds”: [
{
“created_at”: “2022-10-17T03:37:35Z”,
“entry_id”: 97501,
“field2”: “22.2”
}
],

However when trying to capture the field I get the variable {PoolTemperature} resulting in 0.

the Output should be from “field2”:“22.2” …

I have tried so many combinations to get this variable like
response.0.channels.feeds.field2
response.0
response

If I leave the response blank then my variable is Object:Object.

Please could you assist?
Cheers
Mike

Hey Mike - I have been where you are now. If you are just wanting that single data field, I believe it should be coded as:

response.feeds[0].field2

and can be done within the API step, under the “Capture Response” area.

If you want to work with more than one returned json field, I make it a practice to move the entire response (all fields) to an externally defined variable (object) that will allow access outside of the API block. This would look like:


This will allow working with the data returned in the API, in code steps or set steps. In this case, “json.” takes the place of “response.” in any reference to returned API json data fields and should be coded as:

json.feeds[0].field2

Good luck!
Don

Hi Don,

Thank you so much for your post and advice. It worked well and I am grateful for a very quick, concise and detailed response. I have been working on this for about 3 days now, it is my first visit to VoiceFlow and Alex skills.

I am extremely impressed with Voiceflow and now equally amazed and impressed with the forum.

Thank you again.
Cheers
Mike

Glad to hear. Enjoy building voice skills on Alexa with Voiceflow!