Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Python client can't access feed by name
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.

Python client can't access feed by name

by fruity_pebbles on Fri Dec 13, 2019 3:53 pm

I don't seem to be able to access my feed by name. The feed is named "pi0_1_temperature" and its key is "pi0-1-temperature". I create a Client instance, then do

Code: Select all | TOGGLE FULL SIZE
tf = client.feeds(feed_name)


which results in this error:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_IO/client.py", line 274, in feeds
    return Feed.from_dict(self._get(path))
  File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_IO/client.py", line 118, in _get
    self._handle_error(response)
  File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_IO/client.py", line 108, in _handle_error
    raise RequestError(response)
Adafruit_IO.errors.RequestError: Adafruit IO request failed: 404 Not Found - not found - that is an invalid URL, please check the API documentation at https://io.adafruit.com/api/docs to make sure your URL is correct


Using the key instead of the name works OK.

The documentation says that I can use name or ID or key, but that doesn't seem to be the case.

fruity_pebbles
 
Posts: 9
Joined: Tue Dec 14, 2010 11:59 pm
Location: Katy, TX

Re: Python client can't access feed by name

by brubell on Wed Dec 18, 2019 5:11 pm

The documentation says that I can use name or ID or key, but that doesn't seem to be the case.


Where in the Adafruit IO Documentation is this located so I can remove it?

You should always use feed keys when referring to an Adafruit IO Feed in Adafruit IO Python

- brent r.

brubell
 
Posts: 1043
Joined: Fri Jul 17, 2015 10:33 pm

Re: Python client can't access feed by name

by fruity_pebbles on Wed Dec 18, 2019 7:48 pm

It looks like there are a few mistakes on this page: https://adafruit-io-python-client.readt ... feeds.html

The examples for Feed Retrieval show only a key argument for Client(), whereas the example for Feed Deletion correctly shows username and key arguments for Client().

The text for Feed Retrieval includes this statement: "Alternatively you can retrieve the metadata for a single feed by calling feeds(feed) and passing the name, ID, or key of a feed to retrieve". This is what led me astray.

Given that you can only access a feed by key the convention used in a few of the examples seems misleading. The Send Data example has this:

test = aio.feeds('test')
aio.send_data(test.key, 98.6)

To me that implies that 'test' isn't necessarily the feed's key, otherwise why would you bother calling feeds('test') and then using test.key on the next line.

fruity_pebbles
 
Posts: 9
Joined: Tue Dec 14, 2010 11:59 pm
Location: Katy, TX

Please be positive and constructive with your questions and comments.