So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By ESPCrypt
#80785 Hello,

I would like to enquire about the syntax in regards to a POST request and sending a variable within that request.

The below for example will successfully POST a request of 2 specific values.

int httpcode = http.POST("uservalue=112233&user=7");

However what I would like to achieve is sending a String/Variable as one of the values. Something like this -

int httpcode = http.POST("uservalue=(VARIABLEHERE)&user=7");

Is this possible?

Thank you.
User avatar
By Bonzo
#80814 If you build up the string outside the post it will work but I have not tried it the way you want.

Out of interest have you actually tried it?

Code: Select allString data = "uservalue=" + VARIABLEHERE + "&user=7";

int httpcode = http.POST(data);


I think this correct except there might be a problem with variable types.
User avatar
By martinayotte
#80815
Bonzo wrote:
Code: Select allString data = "uservalue=" + VARIABLEHERE + "&user=7";


I think this correct except there might be a problem with variable types.


It should be the following instead :

Code: Select allString data = String("uservalue=") + VARIABLEHERE + "&user=7";