UrbanCCD-UChicago / aot-client-py

The Official Python Client to the Array of Things API
https://api.arrayofthings.org/
Other
6 stars 2 forks source link

TypeError: 'PagedResponse' object is not subscriptable #4

Closed seanshahkarami closed 5 years ago

seanshahkarami commented 5 years ago

Install

Using Docker python:3.7 image.

Collecting aot-client
  Downloading https://files.pythonhosted.org/packages/93/6f/fb93d8ea2493d3b51a6ed35f602bf56bf72e5add608e30d5a6cf94a2cc1f/aot_client-0.2.1-py3-none-any.whl
Collecting requests (from aot-client)
  Downloading https://files.pythonhosted.org/packages/f1/ca/10332a30cb25b627192b4ea272c351bce3ca1091e541245cccbace6051d8/requests-2.20.0-py2.py3-none-any.whl (60kB)
Collecting certifi>=2017.4.17 (from requests->aot-client)
  Downloading https://files.pythonhosted.org/packages/56/9d/1d02dd80bc4cd955f98980f28c5ee2200e1209292d5f9e9cc8d030d18655/certifi-2018.10.15-py2.py3-none-any.whl (146kB)
Collecting idna<2.8,>=2.5 (from requests->aot-client)
  Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests->aot-client)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
Collecting urllib3<1.25,>=1.21.1 (from requests->aot-client)
  Downloading https://files.pythonhosted.org/packages/8c/4b/5cbc4cb46095f369117dcb751821e1bef9dd86a07c968d8757e9204c324c/urllib3-1.24-py2.py3-none-any.whl (117kB)
Installing collected packages: certifi, idna, chardet, urllib3, requests, aot-client
Successfully installed aot-client-0.2.1 certifi-2018.10.15 chardet-3.0.4 idna-2.7 requests-2.20.0 urllib3-1.24

Source

from aot_client import AotClient

client = AotClient()
projects = client.list_projects()

for proj in projects:
    print(f'{proj["name"]} is available at /api/projects/{proj["slug"]}')

Output

Traceback (most recent call last):
  File "/script.py", line 7, in <module>
    print(f'{proj["name"]} is available at /api/projects/{proj["slug"]}')
TypeError: 'PagedResponse' object is not subscriptable
vforgione commented 5 years ago

Good smoke test -- this was taken from the readme and the code here is no longer valid. I'll update accordingly.