Question about http GET request with NodeMCU

Hello all,

I have a snippet of my code below, it is a simple GET request to IFTTT which can trigger things. I have finally got it so the GET request works perfectly, but now I want to add some data.

void loop() {
  // put your main code here, to run repeatedly:

  if(WiFi.status() == WL_CONNECTED){
    
  
  state = digitalRead(button);
  
  if(state == 1){
    HTTPClient http;
    
    http.begin("");

 
    http.begin("http://maker.ifttt.com/trigger/button_pressed/with/key/{my key here}");  
    int httpCode = http.GET();
    digitalWrite(led, HIGH);
    Serial.println("Button pressed!");
    delay(1000);
    digitalWrite(led, LOW);

    state = 0;
 
    if (httpCode > 0) { 
 
      String payload = http.getString();
      Serial.println(payload);                    
 
    }
 
    http.end(); 
 
        }
     }
  delay(25);
  

}

http.begin("Webhooks Integrations - Connect Your Apps with IFTTT{my key here}");

Above is the line of code that is my area of concern. This line works fine but if i go into my web browser and add the lines for adding up to 3 data values with IFTTT

Webhooks Integrations - Connect Your Apps with IFTTT{my key here}?value1=C1&value2=3.34

That line works perfectly when the values are added in.

So my question is, how can I write that line in arduino where I am doing the GET request such that the values are referencing variables that are constantly changing?

I have tried a few different ways, but I just can't figure out how to code it. The goal is to be able to run that GET request that updates the values with IFTTT.

Any help is greatly appreciated, thanks!!

You just need to create a String which contains the values of the variables

String request = "http://maker.ifttt.com/trigger/button_pressed/with/key/{my key here}?value1";
request += String(value1) ;
request += "&value2=" ;
request += String (value2) ;
http.begin (request) ;

Where value1 and value2 contain whatever you want to add, for example

float value2 = 3.34;

You just need to create a String

Go wash your mouth out with soap.

OP: You need to create a string - a NULL terminated array of chars, and use functions like strcpy(), strcat(), sprintf(), etc. to populate the array.