Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Using HTTP PUT to update feed
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.

Using HTTP PUT to update feed

by MrAureliusR on Fri Jan 01, 2016 5:46 am

Hi everyone.

I cannot seem to figure out what the parameter is supposed to be to update the 'last_value' of a feed using an HTTP PUT request. I can use an HTTP request, such as the following:

GET 'http://io.adafruit.com/api/feeds/feednumber?x-aio-key=mykey'

and I get a 200 OK with the feed info.

But when I try and do

PUT 'http://io.adafruit.com/api/feeds/feednumber?x-aio-key=mykey&last_value=value'

I get 400 Error: Bad Request. What is the correct parameter for the last value?

MrAureliusR
 
Posts: 18
Joined: Sat Apr 26, 2014 8:51 pm

Re: Using HTTP PUT to update feed

by MrAureliusR on Sat Jan 02, 2016 3:15 am

After more research, it seems there is a bug and a lapse in the documentation. I posted issue #93 on the GitHub issue tracker. I am able to push updates to the 'last_value', which correctly shows the change, but only in one location. See link for more info: https://github.com/adafruit/io-issues/issues/93

It would be great if the "Guide and Tips" section posted more details about what the proper value names should be. There is only reference to the 'last_value' which seems to be the cause of this bug. Also, http://io.adafruit.com/api/docs/ seems to be down currently.

MrAureliusR
 
Posts: 18
Joined: Sat Apr 26, 2014 8:51 pm

Re: Using HTTP PUT to update feed

by MrAureliusR on Sat Jan 02, 2016 3:38 am

So, after more reading, you have to use POST to update your feed, at a different URL. I summarized how I got it working in the issue, which I've since closed. Again, I highly recommend updating the "Guide and Tips" section. I would love to do it if I could.

MrAureliusR
 
Posts: 18
Joined: Sat Apr 26, 2014 8:51 pm

Re: Using HTTP PUT to update feed

by jwcooper on Mon Jan 04, 2016 11:14 pm

The feed last_value is supposed to be read-only. Sending a new data resource to the feed will automatically update the last_value and last_value_at. Any access to being able to update the last_value should have been removed.

And yes, the documentation definitely needs more work yet!

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

Please be positive and constructive with your questions and comments.