0

I am working with Pi Pico W, it s already connected with Wi-Fi, can see the ifconfig() output.

Furthermore , I am using this urequests code from https://github.com/micropython/micropython-lib/blob/master/python-ecosys/urequests/urequests.py, in yesterdays test almost every thinks was working fine. When tried to update records todays received below error:

Traceback (most recent call last):
File "<stdin>", line 45, in <module>
File "request.py", line 10, in put_request
File "urequests.py", line 188, in put
File "urequests.py", line 76, in request
OSError: -2

I tried check the Api url from Postman but its working fine,extend timeout in request by 10 sec, even I rebot pi. nothing helping.

Dont know whats the cause !

request.py

import urequests
import json
import MSAL

def put_request(id, json_data): 
    
    url = 'url/{}'.format(id)
    headers = {'Content-Type': 'application/json', 'Authorization': '{}'.format(MSAL.get_token())}

    response = urequests.put(url, data=json.dumps(json_data), headers=headers)
    print(response.text)
    response.close()

main.py

def send_data():
    global data
    print('gonna send req here')
    while True:
        while data:
            d = data.pop(0)
            print('This one Going', list(d.keys())[0], list(d.values())[0])
            request.put_request(list(d.keys())[0], list(d.values())[0])
            print('Left over', data)
            utime.sleep(0.5)
        utime.sleep(1)
R. Baraiya
  • 101
  • 1

0 Answers0