Closed biswaKL closed 3 years ago
TinyGsmClient client(modem); HttpClient http(client, server, 80); SerialMon.println(F("Performing HTTP POST request... ")); String dataUpload = "asdfq123123"; http.beginRequest(); int err = http.post("/testing/upload", "application/json;charset=utf-8", dataUpload); if (err != 0) { http.stop(); Serial.println(F("failed to connect")); delay(1000); } http.sendHeader("id", "asdf1234"); http.sendHeader("File-Type", "txtfile"); http.endRequest(); int statusCode = http.responseStatusCode(); String response = http.responseBody(); http.stop();
Solved it, content length and content type are compulsory header. and need to use: http.post("/testing/upload");
http.post("/testing/upload");
http.beginBody(); http.print(data); http.endRequest();