You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In working on a project and reading the docs for PortalBase.network I ran into a lot of confusion seeing that fetch() has headers as a list type[0].
Seeings how header params are nearly always a dictionary I decided to pass a dictionary and it worked. Also, from what I understand the underlying adafruit_requests is based on they Python Requests library, which also uses a dictionary for headers params[1].
When I try and pass a list I encounter the following traceback:
File "code.py", line 34, in <module>
File "code.py", line 30, in fetch_data
File "adafruit_portalbase/network.py", line 548, in fetch_data
File "adafruit_portalbase/network.py", line 467, in fetch
File "adafruit_requests.py", line 684, in get
File "adafruit_requests.py", line 567, in request
File "adafruit_requests.py", line 565, in request
File "adafruit_requests.py", line 494, in _send_request
TypeError: list indices must be integers, not str
Looking into adafruit_requests it does indeed look to expect a dict[2].
In working on a project and reading the docs for PortalBase.network I ran into a lot of confusion seeing that fetch() has headers as a list type[0].
Seeings how header params are nearly always a dictionary I decided to pass a dictionary and it worked. Also, from what I understand the underlying adafruit_requests is based on they Python Requests library, which also uses a dictionary for headers params[1].
When I try and pass a list I encounter the following traceback:
Looking into adafruit_requests it does indeed look to expect a dict[2].
[0] https://github.com/adafruit/Adafruit_CircuitPython_PortalBase/blob/main/adafruit_portalbase/network.py#L450
[1] https://docs.python-requests.org/en/master/user/quickstart/#custom-headers
[2] https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/master/adafruit_requests.py#L533
The text was updated successfully, but these errors were encountered: