Dumping as a JSON string is already done in the request() call. See source code for urequest:
https://pypi.org/project/micropython-urequests/#files
Relevant part in request() call (library is MIT licensed, anyway this is just a snippet):
The Sonoff firmware may be expecting something in the HTTP headers. MicroPython and JavaScript examples failed, but PHP and Talend API Tester worked. The JavaScript and PHP examples were almost similar, yet one failed. So the need to check the entire HTTP message sent, see what the two did differently.
From this URL, it sounds like Sonoff wants to be DIY friendly:
https://sonoff.tech/diy-developer/
I believe Sonoff is not deliberately putting up surprise barriers -- they may have only tested it on limited languages/frameworks. It may be something the Sonoff firmware is relying on, maybe Content-Length. Any client which didn't add that in the HTTP header will bork the transaction. Something like that could happen. If on a PC, I might use Wireshark to capture the sockets comms.
[Edit]: Or we can look at the PHP source code and find out how it formatted the POST request. Etc.
https://pypi.org/project/micropython-urequests/#files
Relevant part in request() call (library is MIT licensed, anyway this is just a snippet):
Code:
if json is not None: assert data is None import ujson data = ujson.dumps(json) s.write(b"Content-Type: application/json\r\n")
From this URL, it sounds like Sonoff wants to be DIY friendly:
https://sonoff.tech/diy-developer/
I believe Sonoff is not deliberately putting up surprise barriers -- they may have only tested it on limited languages/frameworks. It may be something the Sonoff firmware is relying on, maybe Content-Length. Any client which didn't add that in the HTTP header will bork the transaction. Something like that could happen. If on a PC, I might use Wireshark to capture the sockets comms.
[Edit]: Or we can look at the PHP source code and find out how it formatted the POST request. Etc.
Statistics: Posted by katak255 — Sun Oct 06, 2024 2:10 am