How to add string to HTTP POST request

Hi. I would like to add a string to my HTTP POST request. I want the string to be based off of whatever input i type in to the serial monitor. This I know how to do, but it still doesn't send the POST request. I think the problem is that the post request is an int called httpCode, and therefore I can't store my string in the int. The int I'm talking about is defined as follows:

int httpCode = http.POST("number=3&submit=enter"); //Send the request

Basically I want the post requests number to be whatever number i type into the Serial Monitor. So If I type in the number 5 in the serial monitor it will then send the request http.POST("number=5&submit=enter"), but since I'm trying to add a string to the int I can't get this to work.

For good measures I'm posting the essential part of the code below.

}

void loop() {

HTTPClient http; //Declare object of class HTTPClient

http.begin("http://192.168.111.54:80/php-login/login.php"); //Specify request destination
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header

int httpCode = http.POST("number=3&submit=enter"); //Send the request
String payload = http.getString(); //Get the response payload

Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload

http.end(); //Close connection

}

delay(30000); //Send a request every 30 seconds

}

Any with this problem help is greatly appreciated!

No, no, the POST is not defined as an int. The int you're talking about is the result of the POST request. It's the HTTP status code and it tells you whether the request was successful or not. The payload (body) is supplied as the parameter to http.POST(...). Just replace whatever data you have there by the data you want to send.

Pieter

The only place I define my request is in the int. I don't have any data in the string payload, therefore there is nothing to replace. The snippet of code I posted above is literally from my program - no edits or anything.

The only place I define my request is in the int.

Bullshit. This statement makes no sense.

For good measures I'm posting the essential part of the code below.

For good measures, I'm posting the essential part of the answer below.

You need to make some changes to your code.

For a COMPLETE answer, post ALL of your code.

PaulS:
Bullshit. This statement makes no sense.
For good measures, I'm posting the essential part of the answer below.

You need to make some changes to your code.

For a COMPLETE answer, post ALL of your code.

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

void setup() {

Serial.begin(115200); //Serial connection
WiFi.begin("ZBC", ""); //WiFi connection

while (WiFi.status() != WL_CONNECTED) { //Wait for the WiFI connection completion

delay(500);
Serial.println("Waiting for connection");

}

}

void loop() {

if(WiFi.status()== WL_CONNECTED){ //Check WiFi connection status

void loop() {

HTTPClient http; //Declare object of class HTTPClient

http.begin("http://192.168.111.54:80/php-login/login.php"); //Specify request destination
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header

int httpCode = http.POST("number=3&submit=enter"); //Send the request
String payload = http.getString(); //Get the response payload

Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload

http.end(); //Close connection

}else{

Serial.println("Error in WiFi connection");

}

delay(30000); //Send a request every 30 seconds

}

void loop() {
 
 if(WiFi.status()== WL_CONNECTED){   //Check WiFi connection status
 
   void loop() {

That crap won't even compile!