-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with API request on PyPortal #120
Comments
That's a pretty large return value. Can you make a query to the same server with the same authentication that returns a much smaller result and see if it works? |
I have just tried without supplying the header, a browser or python code return and the circuit python code (pasted below) still return The code is below. Many thanks! import time
import board
import busio
import adafruit_requests as requests
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
try:
from secrets import secrets
except ImportError:
print('Secrets key such as WIFI are kept in secrets.py, please add them there!')
raise
esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
requests.set_socket(socket, esp)
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
print('\nPYPORTAL found and in idle mode')
# CONNECTING TO WIFI
print('-' * 40, 'Connecting to WIFI...','-' * 40, '\n')
while not esp.is_connected:
try:
time.sleep(1)
esp.connect_AP(secrets['ssid'], secrets['password'])
except RuntimeError as e:
print('Could not connect to WIFI, retrying: ', e)
continue
print('Connected to', str(esp.ssid, 'utf-8'), '\tRSSI:', esp.rssi, ' IP address is', esp.pretty_ip(esp.ip_address), '\n')
# TEST WIFI - OK
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
print("Fetching text from", TEXT_URL)
r = requests.get(TEXT_URL)
print(r.text)
r.close()
# API CALL - not OK
url = 'https://prim.iledefrance-mobilites.fr/marketplace/stop-monitoring?MonitoringRef=STIF:StopPoint:Q:43198:'
req = requests.get(url, headers="")
req.json()
|
By adding some debug prints to requests... it's failing here with
|
Thanks for looking into it... I hope it can be solved! |
Ah... trying this on ESP32-S2, it does indeed get the same |
Turning debug modes on doesn't yield anything useful, we just don't have access to the low-level handshake details currently from the NINA firmware. esp._debug = val # ESP32SPI debug mode: 0, 1, 2, or 3
esp.set_esp_debug(co_val) # NINA debug mode: True or False (btw, testing using CircuitPython 7.3.3, NINA 1.7.4, and adafruit_requests 1.12.10) |
Thanks, do you think it can be/will be solved? |
@ysiegel29 You may want to try the solution from: |
Hello,
I am trying to download a json from an API on a pyportal Titano, the response is around 11k and work no problem in my desktop python
I get a "sending request failed"
other api work, wifi connection is ok
I have updated firmware to 1.7.4
I have tried circuit python 7.3.3 and 8.0.0b
updating the lib accordingly
the API is "https://prim.iledefrance-mobilites.fr/marketplace/stop-monitoring?MonitoringRef=STIF:StopPoint:Q:43198:" but you need a key
I have read in a previous issue where @anecdata commented that there could be certificat issue (not sure if it should be solved by latest firmware). But did not managed to provide a certificate manually.
Could someone help?
Many thanks!
The text was updated successfully, but these errors were encountered: