Arduino-esp32: send multiple variables using one http.POST request ESP32

Created on 9 Oct 2018  路  8Comments  路  Source: espressif/arduino-esp32

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: 2018
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 7

Description:

Hello Everyone,

i'm trying to send(POST) multiple(2or3) variables using http.POST , e.g http.POST(variable1,variable2) something like this, but unable to do so. can anyone please help me in doing this ?

Thanks
Anand

whatsapp image 2018-10-09 at 11 06 01 am

stale

Most helpful comment

@chegewara

http.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpResponseCode = http.POST(date=dayStamp&timeis=timeStamp);
format of dayStamp = 08:09:2018
timeStamp = 12:14:34

error message : no match for 'operator&' (operand types are 'String' and 'String')

All 8 comments

You can pass one long string which is in form of:

grant_type=refresh_token&client_id=amzn1.application-oa2-client&refresh_token=Atzr%7CIwEBID5spY2iwIvtUw5sBKwzHSML

But you have to set header:
Content-Type: application/x-www-form-urlencoded

@chegewara

http.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpResponseCode = http.POST(date=dayStamp&timeis=timeStamp);
format of dayStamp = 08:09:2018
timeStamp = 12:14:34

error message : no match for 'operator&' (operand types are 'String' and 'String')

httpResponseCode = http.POST("date=dayStamp&timeis=timeStamp");

whatsapp image 2018-10-09 at 12 21 41 pm
i am getting this on server side. but i want something like 08:11:2018 12:23:45
so that i can ,after processing the data, extract the variables

I understand, i just gave you example how to fix that error. Now you have to build string before you pass it as argument. Something like that:

char _post[40];
sprintf(_post, "date=%s&timeis=%s", dayStamp, timeStamp);
httpResponseCode = http.POST(_post);

Just check how to convert dayStamp and timeStamp to string (google it).

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This stale issue has been automatically closed. Thank you for your contributions.

hey
Is there any restriction on sending data?
I mean I am sending a file content as one string and after 210 lines it couldn't send
whats a problem?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jhowkis picture jhowkis  路  3Comments

huming2207 picture huming2207  路  4Comments

ComputerLag picture ComputerLag  路  3Comments

0x1abin picture 0x1abin  路  3Comments

OAXP picture OAXP  路  4Comments