Issue with getting feeds from API | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Issue with getting feeds from API
No permission to create posts
May 9, 2019
10:04 am
Avatar
Wilice K
Ukraine

Gold
Members
Forum Posts: 38
Member Since:
February 5, 2016
sp_UserOfflineSmall Offline

Hello everyone!

I have encountered the following issue with getting feeds from api.thingspeak.com
Before yesterday everything worked fine since 2015

For now requesting feeds I got the following data:

Request as example: https://api.thingspeak.com/channels/38604/feeds.json?results=2&api_key=
Replayed data:
{"channel":{"id":38604,"name":"Village","description":"Meteo","latitude":"","longitude":"","field1":"Temperature","field2":"Humidity","field3":"Pressure","field4":"Pressure sea","field5":"Rain level","field6":"Temp int","field7":"Humid int","created_at":"2015-05-19T16:38:27Z","updated_at":"2018-08-16T10:31:46Z","last_entry_id":799348},"feeds":[{"created_at":"2019-05-09T13:43:49Z","entry_id":799347,"field1":null,"field2":null,"field3":null,"field4":null,"field5":null,"field6":"18.5;field7=49.2","field7":null},{"created_at":"2019-05-09T13:45:37Z","entry_id":799348,"field1":"11.1;field2=99.9;field3=744.1;field4=755.3;field5=0","field2":null,"field3":null,"field4":null,"field5":null,"field6":null,"field7":null}]}

There are some strange formatting of JSON reply:
This one:
"field6":"18.5;field7=49.2","field7":null
And this one:
"field1":"11.1;field2=99.9;field3=744.1;field4=755.3;field5=0","field2":null,"field3":null,"field4":null,"field5":null

Looks like data processor defect.
The most interesting thing that all widgets in my account on Thingspeak shows correct graphics.

I will be so appreciated if someone help me with this strange issue!

May 10, 2019
12:21 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 302
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

I looked at the data in the back end and it appears that the way you are sending your data is the root cause of the issue. The request our servers see is

http://api.thingspeak.com/update.json?api_key=__YOUR_API_KEY__&field1=10.1;field2=99.9;field3=745.5;field4=756.8;field5=0

alternating with

http://api.thingspeak.com/update.json?api_key=__YOUR_API_KEY__&field6=18.3;field7=44.9

Note that the field numbers appear to be separated by ';' instead of the ampersand '&' specifying it to be a different query parameter. This causes ThingSpeak to treat the entire string as a value for field1 or field6, for each of the requests.

You can confirm this by downloading the data from your channel in the 'Data Import/Export' tab of your channel.

Can you check the code on your device that is sending the data to ThingSpeak and see if updating that resolves the issue?

May 10, 2019
2:34 pm
Avatar
Wilice K
Ukraine

Gold
Members
Forum Posts: 38
Member Since:
February 5, 2016
sp_UserOfflineSmall Offline

Thank you for your quick reply!
You are right, my devices send requests with semicolon separeted fields.
However it sends HTTP POST requests wth data like follows:
POST https://api.thingspeak.com/update
api_key=XXXXXXXXXXXXXXXX
field1=5;field2=10;field3=7

And one more thing, I downloaded data from the channel and I encountered the strange change as it were described before.
Please look at this:
2019-05-08 16:14:50 EEST,799149,,,,,,20.0,46.7,,,,
2019-05-08 16:15:08 EEST,799150,12.6,99.9,746.2,757.6,0,,,,,,
2019-05-08 16:30:02 EEST,799151,,,,,,20.0,46.7,,,,
2019-05-08 16:30:34 EEST,799152,12.1,99.9,746.3,757.7,0,,,,,,

2019-05-08 16:45:14 EEST,799153,,,,,,20.0;field7=47.0,,,,,
2019-05-08 16:45:35 EEST,799154,12.3;field2=99.9;field3=746.4;field4=757.7;field5=0,,,,,,,,,,
2019-05-08 17:00:15 EEST,799155,,,,,,20.0;field7=46.7,,,,,
2019-05-08 17:00:47 EEST,799156,11.8;field2=99.9;field3=746.4;field4=757.7;field5=0,,,,,,,,,,
2019-05-08 17:15:29 EEST,799157,,,,,,19.8;field7=46.9,,,,,
2019-05-08 17:15:45 EEST,799158,11.8;field2=99.9;field3=746.5;field4=757.8;field5=0,,,,,,,,,,

Before 2019-05-08 16:45:14 EEST during 3 years everything was OK ;).
But since this time the issue has appeared.
Nothing was changed on my side but I suppose something was changed in request text processor on cloud side.

UPDATE:
And I have just done the following experiment:

Get Request:
https://api.thingspeak.com/update.json?api_key=&field1=123;field2=321

Reply:
{"channel_id":38604,"created_at":"2019-05-10T18:41:47Z","entry_id":799579,"field1":"123","field2":"321","field3":null,"field4":null,"field5":null,"field6":null,"field7":null,"field8":null,"latitude":null,"longitude":null,"elevation":null,"status":null}

So, GET requests still work fine with semicolons ";"
The issue is in POST requests.

Could you please help me with the issue.
Thanks in advance!

May 11, 2019
10:37 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 302
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

That's an interesting finding. I'd say what the POST request is doing is correct. That the GET requests work that way need to be looked at.

The best recommendation I can make is to update your device to use the ThingSpeak Support Library here: https://github.com/mathworks/thingspeak-arduino

The library abstracts many of the details and gives you high-level functions you can call to update a ThingSpeak channel.

May 11, 2019
1:56 pm
Avatar
Wilice K
Ukraine

Gold
Members
Forum Posts: 38
Member Since:
February 5, 2016
sp_UserOfflineSmall Offline

That is great recommendation, but this is remote device and any sw change is quite expensive.
Could you just fix the defect with POST request.
It should work as needed!

Thanks in advance!

May 14, 2019
3:50 pm
Avatar
Wilice K
Ukraine

Gold
Members
Forum Posts: 38
Member Since:
February 5, 2016
sp_UserOfflineSmall Offline

Dear Vinod,
Have you got any updates regatding issue with backend after it was changed 8 May?
When can I expect that it will be fixed?

I will be so appreciated for youe quick reply!

With BR,
Wolice.

May 14, 2019
9:55 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 302
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

We investigated this and the app is behaving to spec. It appears your code is relying on incorrect behavior which we don't intend to regress to.

I understand all too well about updating code being expensive. The best solution I can give you without having to change your device code is to consider writing MATLAB code that parses the results in field1 and write it to multiple fields of a different channel. You can tie this MATLAB code to an on data insert react to make it all automatic.

May 18, 2019
5:06 am
Avatar
Wilice K
Ukraine

Gold
Members
Forum Posts: 38
Member Since:
February 5, 2016
sp_UserOfflineSmall Offline

Vinod said

We investigated this and the app is behaving to spec. It appears your code is relying on incorrect behavior which we don't intend to regress to.

 

So, which field separtor have I use to with POST request?
Now semicolon is used ";".

May 22, 2019
10:52 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 669
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

You should use ampersand '&'.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
32 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Matthewdupreez1, sbhunu, pabcstar, johnhutcheson1, madhuhada, dayne

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457