I've been trying to send a put request from my esp8266 for a while not but I can't figure out why it doesn't work and there are barely any posts about put requests online
I keep getting errors around int httpCode = http.sendRequest("PUT", String(data));
Error log: https://gist.github.com/dkbay/ab3fedf5e89d841d25b24fb829df74ef
#include <ESP8266HTTPClient.h>
#define LED_BUILTIN 2
const char* ssid = "Some SSDI";
const char* password = "Some wifi password";
int wifiStatus;
void setup() {
Serial.begin(115200);\
pinMode(LED_BUILTIN, OUTPUT);
delay(200);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Your are connecting to;");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
Serial.print(".");
}
}
void loop() {
wifiStatus = WiFi.status();
if(wifiStatus == WL_CONNECTED){
HTTPClient http;
http.begin("http://google.com/");
http.addHeader("Content-Type", "application/json");
String data = "{\"on\":false}";
int httpCode = http.sendRequest("PUT", String(data));
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
http.end();
Serial.println("");
Serial.println("Your ESP is connected!");
Serial.println("Your IP address is: ");
Serial.println(WiFi.localIP());
}
else{
Serial.println("");
Serial.println("WiFi not connected");
}
delay(1000); // check for connection every once a second
}
sendRequest("PUT", data.c_str());