How to send a Post request?

Good morning everyone;
I have a program written in c (Arduino) with which I read the data of my photovoltaic system, through the following POST request:
http.begin(client, “http://” + IPaddress + “/lala.cgi/”); //HTTP
http.addHeader(“Content-Type”, “application/json”);
int httpCode = http.POST("{"ENERGY":{"GUI_INVERTER_POWER":"","GUI_HOUSE_POW":"","GUI_BAT_DATA_POWER":"",\ “GUI_GRID_POW":"","GUI_BAT_DATA_FUEL_CHARGE":""}}”);

can i have your help?, i can’t do it with kodular, at most i can get only a simple {“ENERGY”:
thanks to anyone who can help me

…with the help of curl-to-blocks

you wrote that program yourself, but why so complicated?
can’t you use a GET request and just tell the program “give me the data”?

what is the response content in your case?

Taifun

Hello and thanks for the reply
get request doesn’t work on my inverter
the data I should receive (done with POSTMAN) are:
{
“ENERGY”: {
“GUI_INVERTER_POWER”: “fl_4356E001”,
“GUI_HOUSE_POW”: “fl_43BFD6E4”,
“GUI_BAT_DATA_POWER”: “fl_C31546E3”,
“GUI_GRID_POW”: “fl_C26C47AE”,
“GUI_BAT_DATA_FUEL_CHARGE”: “fl_42C40000”
}
}

in BODY: {“ENERGY”: {}}

this is the link where I got my inspiration: Query the hidden API of your SENEC photovoltaic appliances

Web1.RequestHeaders => make a list:

You can simply add this block and it should work I guess:

blocks(5)

unfortunately it doesn’t work
the result on Label1 is: {“ENERGY”:

you can use a list of lists or a alternatively as @Amidonu is using it a dictionary to define a request header

you also can try to put the complete string as it is
"{"ENERGY":{"GUI_INVERTER_POWER":"","GUI_HOUSE_POW":"","GUI_BAT_DATA_POWER":"", “GUI_GRID_POW":"","GUI_BAT_DATA_FUEL_CHARGE":""}}”
into a text block and the text block as text into the PostText method

Taifun

@Taifun
FANTASTIC!!! WORKS.
Thank you very much

great
please provide a screenshot of the working solution then
Taifun

certainly, I create a structure and send you screenshots

1 Like

I’m still here asking for help
the data imported with the POST request are in hexadecimal format (8 bytes) and I should transform them into FLOAT or INT to display them
example: hex 450B9AB0 = float 2233.67
can you help me?

Maybe this discussion can help

You can also try

Or do another search in the community…

Taifun

solved with the help of Profile - Juan_Antonio - MIT App Inventor Community
I hope it can be useful to anyone

after some adjustments, this is the final result.
Thanks again for the help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.