Hello,
I try to post some data to my server using JSON and HTTP.
I receive the correct content length header but the body shows empty.
Thanks for help here the code snipped I use:
Serial.print("Connecting to ");
Serial.println(server);
if (!client.connect(server, port)) {
Serial.println(" fail");
delay(10000);
return;
}
Serial.println(" success");
msg = "{"UL1":0.027327521,"UL2":0.118873939,"UL3":0.13162981}";
if (client.connect(server,port)) {
Serial.println("connected");
client.println("POST /debug HTTP/1.1");
client.println("Host: MYIPADRESS");
client.println("Content-Type: text/plain;"); //application/json
client.print("Content-Length: ");
client.println(msg.length());
client.println();
client.println(msg);
uint32_t timeout = millis();
while (client.connected() && millis() - timeout < 10000L) {
// Print available data
while (client.available()) {
char c = client.read();
Serial.print(c);
timeout = millis();
}
}
}
}
Debug and AT command log
23:05:09.729 -> Modem connecting to Server: OK
23:05:16.014 -> Connecting to MYIPADRESS
23:05:16.455 -> success
23:05:16.923 -> connected
23:05:18.168 -> HTTP/1.1 200 OK
23:05:18.168 -> X-Powered-By: Express
23:05:18.168 -> Access-Control-Allow-Origin: *
23:05:18.275 -> Content-Type: text/html; charset=utf-8
23:05:18.318 -> Content-Length: 4
23:05:18.456 -> ETag: W/"4-MByqNJgqvz3ZpGITR5RzlLTEsBo"
23:05:18.490 -> Date: Sun, 06 Mar 2022 22:05:17 GMT
23:05:18.591 -> Connection: keep-alive
23:05:18.591 ->