ESPHome one http request with multiple sensors

Hello,

i have esphome with a DHT22 sensor and i want to save the data with one request in influxdb.
At the moment im only able to save either the temperature or the humidity with one request:

sensor:
  - platform: dht
    model: DHT22
    pin: D1
    temperature:
      id: temp
      name: "Living Room Temperature"
      on_value:
        then:
          - http_request.post:
              url: http://192.168.178.4:8086/api/v2/write?org=main&bucket=tmp
              headers:
                Authorization: 'Token x'
              body: !lambda |-
                char buf[64];
                sprintf(buf, "%0.1f", id(temp).state);
                return ((std::string) "dht22,device_key=0001,room=livingroom temperature="+buf).c_str();
    humidity:
      name: "Living Room Humidity"
    update_interval: 60s

If i also want to save the humidity i would have to create a second on_value with nearly the same config i have in temperature but this would also result in a second post request.
Is it somehow possible to send one request with both values? E.g. one on_value for both sensors?

interval:
  - interval: 1min
    then:
      - http_request.post:
          url: !lambda |-
            char buf1[64];
            char buf2[64];
            sprintf(buf1, "%0.1f", id(hum).state);
            sprintf(buf2, "%0.1f", id(temp).state);
            return ((std::string) "https://api.thingspeak.com/update?api_key=1234567890234567&field1=" + buf1 + "&field2=" + buf2).c_str();

I have a similar post but using the Nabu Casa URL.
My aim was to be able to send info from all the sensors… Could this be replicated?

Hi,

Can you please post your final code, I used it like this, but maybe there is a better coding:

body: !lambda |-
              char buf1[64];
              char buf2[64];
              char buf3[64];
              sprintf(buf1, "%0.1f", id(temp).state);
              sprintf(buf2, "%0.1f", id(temp2).state);
              sprintf(buf3, "%0.1f", id(temp3).state);
              return ((std::string) "temperature,device=TEST,id=1 value="+buf1 + "\n" + "temperature,device=TEST,id=2 value="+buf2 + "\n" + "temperature,device=TEST,id=3 value="+buf3 ).c_str();

Many thanks!