HttpPost using UIflow
-
You need a webserver to work with POST - GET requests
-
You should write a own parser for this response.
You could use a block:
text->replace oldvalue with newvalue in yourresponse
to remove uneccessary values from your responsewhere as:
oldvalue you assign "<HTML>"
newwalue you assign "" (empty string)
yourresponse assign your response variableAnd repeat this for all other html markups exists in your response. When you have only interested values
ua 1 ub 1 ... ul 1
when you could use: list -> make list from text yourresponse with delimiter " " -
UiFlow Example?
-
something like this:
-
My problem is before, how to get the data, i tested this but it doesn't work!
"Get data" fail.
-
Maybe you need change POST to GET. Print get data and status code in the succes and failure part of http block. Finally try use another software to test debug requests you are send. Or read Api documentation for your service/device.I already use Restler and Pydroid3 on Android for test http connection. But i wrote code in pure python and later i create own custom block to read data from services.
How do you get data from your first post? (this html page).
-
i use a browser and i give this Url :
"http://79.8.125.79:8084/?onx"
and then i get:
<html>
<head>
</head>
<body>
ua 1 ub 1 uc 1 ud 1 ue 1 uf 1 ug 1 uh 1 ui 1 ul 1
</body>
</htmlthere are lot of python example to get this result, but i want to replay it with UiFlow
I tested with another software using HttpPost and HttpGet, both it work the response is different.
This Url activate small board with 8 relè with a simple web server, few commands and i can control it.
I want to do it using UiFlow example and M5stack basic. -
maybe you should try this code:
also try add block to connect to your wifi and download code to device (not play button)
-
@robalstona
Tested, and it doesn't work, no response and it doesn't send the command.I tested using the browser and i get the response and the hardware does what it have to do.
-
@franco try change address to: http://ip_address_of_your_wifi_router and check if yo get any tesponse. You must give back something.
I change adress to:https://www.google.com/index.html and i getback this response. I receive error, but show the server response for this request
-
@franco what is the m5stack device is talking to? It appears to be a web server or similar, but what is it? Also, I would recommend adding another label to the m5stack/m5stickC to get the HTTP status code. This would give an indication if the flow is timing out (no response or eventually failure after the timeout period) or what the response is with the HTTP error code (see this link for a list of error codes).
Also, you showed two http addresses above, http://79.8.125.79:8084/?onx and http://192.168.1.123/?offx. I assume one is on a public network and the other is on your private/local network. So you would also need to make sure the servers are not blocking traffic from the network the m5stack/m5stickC is on.
-
@franco see the python code tab. The urequests statement comes immediately after the try statement. If something goes wrong, e.g. a typo in the address (non-existent address), this requests instruction will be treated as if it never started and the blocks Get Data and Get Status Code will not return anything and probably their use in this case cause a error.