Score:0

OSError: -2, File "urequests.py", line 76, in request

ve flag

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)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.