0

Dashboard not showing feed change using curl
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Dashboard not showing feed change using curl

by richarduk on Sat Nov 14, 2015 4:29 pm

I have a yun, the yun can change the feed value and the dash board shows the changes. I can also see the changes when I query it with curl and a https call. If I use a curl call to set the value the dash board does not update. But the value does when I view it with the same curl call that viewed the changes submitted by the yun.

The dashboard is from the yun example.

To get the value:
Code: Select all | TOGGLE FULL SIZE
curl  http://io.adafruit.com/api/feeds/button.json?X-AIO-Key= My Key


To set the value I used a file: set_button.json
Code: Select all | TOGGLE FULL SIZE
{"last_value":1}

To clear it a file: clear_button.json
Code: Select all | TOGGLE FULL SIZE
{"last_value":0}


The curl call is:
Code: Select all | TOGGLE FULL SIZE
curl -H "Content-Type: application/json" -X PUT --data @set_button.json http://io.adafruit.com/api/feeds/button.json?X-AIO-Key= My Key


Any ideas?

Thanks, Richard.

richarduk
 
Posts: 64
Joined: Tue Nov 05, 2013 4:55 pm

Re: Dashboard not showing feed change using curl

by awall on Sat Nov 14, 2015 6:55 pm

Hi Richard, i discussed this in the Bug forum (see https://github.com/adafruit/io-issues/issues/70) and I was told that "last_value" was designed to be a read-only property.
Currently this is not enforced, so you can do a PUT or a PATCH of "last_value" but it works inconsistently in some views and not in others.

So the correct (and working) ways to send data to a feed is to use a POST with "value":

Code: Select all | TOGGLE FULL SIZE
curl -H "Content-Type: application/json" -X POST -d "{\"value\":\"123\"}" -H "x-aio-key: ...ABCD..." http://io.adafruit.com/api/feeds/<...feednumber...>/data.json

And if you need to update the value of an existing data point, then use PUT or PATCH with "value":

Code: Select all | TOGGLE FULL SIZE
curl -H "Content-Type: application/json" -X PUT -d "{\"value\":\"777\"}" -H "x-aio-key: ...ABCD..." http://io.adafruit.com/api/feeds/<...feednumber...>/data/<...datapoint_id...>.json

I think it's time for me to post a complete CURL guide for REST API...

Regards
Andrea

awall
 
Posts: 24
Joined: Sat Sep 20, 2014 10:40 am

Re: Dashboard not showing feed change using curl

by richarduk on Sat Nov 14, 2015 7:46 pm

Thanks for the info, seems the feeds documentation needs to be updated as that says to use last_value to update an existing value. I never got as far as reading the part about the data POST. I guess that part in feeds can be just deleted to stop confusing noobs like me. :)

Thanks for the help, working now.

richarduk
 
Posts: 64
Joined: Tue Nov 05, 2013 4:55 pm

Re: Dashboard not showing feed change using curl

by jwcooper on Mon Nov 16, 2015 1:39 pm

I've removed the old docs. Thanks for the reminder. ;)

The latest docs are found here:
https://io.adafruit.com/api/docs

last_value is indeed supposed to be read-only.

jwcooper
 
Posts: 670
Joined: Tue May 01, 2012 9:08 pm

Please be positive and constructive with your questions and comments.