arduino-libraries / WiFi_for_UNOWiFi_rev1

Arduino WiFi Library
7 stars 10 forks source link

POST body isn't being send #13

Open tkreis opened 7 years ago

tkreis commented 7 years ago

So I got this to work:

Serial.begin(9600);
ESP esp(&Wifi);
Wifi.begin();
REST rest(&esp);
Serial.println(rest.begin(MYIP));
rest.get("/", "");
char data[256];
Serial.println(rest.getResponse(data, 256)); // prints the status code or 0 on failure
Serial.println(data);

When trying to do the same with a post

Serial.begin(9600);
ESP esp(&Wifi);
Wifi.begin();
REST rest(&esp);
Serial.println(rest.begin(MYIP));
rest.post("/", "POSTBODY");
char data[256];
Serial.println(rest.getResponse(data, 256)); // prints the status code or 0 on failure
Serial.println(data);

The request is being made but the post body is always empty. I'm not sure if it's a bug, or if I'm using it wrong.

Lastly, how is the HTTP request being formed, who sets the all of headers (content-type/ content-length etc.). I wasn't able to find anything in the source code about it.