Web server rest api, multiple POSTs

I’m running esphome web server and separate esp32 client (not esphome) which updates Number components value through Rest api calls. So from client I make POST request like: ip/number/number_id/set?value=25 and it’s working fine. But I need to update five Number components and I can’t figure out how to do it. Can I do it somehow in one POST or can I do several POSTs within one http session?

You will need to do several POSTs - the sensor ID is part of the URL using this method, thus you can only provide the one.

Thank’s, I was expecting so, since I didn’t find anything from documentation… What about multiple posts in one session?
Something like:


Or do I really need new session for every post?

The documentation doesn’t actually say you need a new session - all I can recommend is that you try it and see the result.

Thank’s. but how should I formulate it? I mean, since Id is part of the url which I normally insert in http.begin(url)

That’s not really an ESPHome question - I haven’t coded a http client for Arduino for a while and a lot of the users on this forum would never have done so.

I will try and find time to have a look at some old code but maybe one of the other forum users can assist.

I agree. I was hoping to find generic component with multiple parameters, something like Light component which has plenty of parameters… but all of them are limited to tight predictions. Thank you anyway!

Alternatively you can just copy the web server component as a local “external component” and modify it yourself to work as you want. Of course you need to be able to do a bit if C++ but what you ask is doable but will need a mod to handle setting variables via POST instead of the GET url. I might add it to my own version of it. for example the url would need to be:
/<domain>/<cmd> where domain and cmd can be /number/set
and your post would contain the POST data as json
I suggest json as you can set multiple id’s and arbitratry data much easier then using urlencoded values at the cost of a bit of extra manipulation.

Hi, that’s what I was expecting to find in Rest Api to start with… But generic number doesn’t have variables, Light component have several but they are limited from 0 to 255. And I needed from -250 to 4500. To modify web server is beyond my skills.