Closed BusterRaid closed 3 years ago
@BusterRaid Feeds are referenced by their keys, not their names. What's the feed's key on Adafruit IO?
Closing for now, please re-open if you have further clarification for what should be changed in the documentation
@brentru Think I've run into the same problem OP is describing. I can create a feed name with capital letters and push data to it, but when I try to access it again I receive a "400 Bad Request" error. As an example, the following code runs as expected the first time, but results in an error if it's run a second time:
from Adafruit_IO import Client, Feed, RequestError
ADAFRUIT_IO_USERNAME = 'MS3FGX'
ADAFRUIT_IO_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
feedname = "TEST"
try:
feed = aio.feeds(feedname)
except RequestError:
feed = aio.create_feed(Feed(name=feedname))
aio.send_data(feed.key, "1234")
The error is especially confusing since I can see that the "TEST" feed has been created on the IO page, and that the data has been received. If I change the "feedname" variable to "test", not only does the error go away, but the data ends up in the original "TEST" feed.
Perhaps this is intended behavior, but it's not very intuitive. Logically, whatever name I use to create the feed should work when I want to access it later.
This occurs on an "emulated" Raspberry Pi.
Guest Operating System: Raspberry Pi Debian GNU/Linux 9.13 Kernel: Linux 4.9.0-13-amd64 Architecture: x86-64
Python version: Python 3.5.3 (default, Jul 9 2020, 13:00:10) [GCC 6.3.0 20170516] on linux
AdaFruitIO version: Adafruit_IO.version 2.4.0
Using a Feed name which contains any upper case characters results in an error response, when following the "Quickstart" documentation, e.g: Create a Feed via the GUI OR programmatically called "Foo". Attempt to programmatically send data to the feed "foo" succeeds:
Attempt to programmatically send data to the feed "Foo" fails:
aio.send('Foo', 100)
Documentation shows an example where a mixed case name is used:
[]https://adafruit-io-python-client.readthedocs.io/en/latest/quickstart.html?highlight=send#quickstart(url)
... In this case the name "Foo" is suggested by the documentation as a suitable Feed name, but this would actually fail.