So I'm trying to add data to a adafruit IO feed through webhooks and the WiFi client on my Huzzah Feather and the HTTPClient, but all I get is http code -1. I can add data through curl so the webhook works, and the http.begin result in a true. The Huzzah Feather is connected to WiFi. Anyone that have experienced the same problem?
Code: Select all
HTTPClient http;
Serial.print("[HTTP] begin...\n");
bool result = http.begin("https://io.adafruit.com/api/v2/webhooks/feed/7q6NkmC1sUHb65cQ7yAFskWMQx3j", fingerprint);
Serial.print("Begin result: ");
Serial.println(result);
http.addHeader("Content-Type", "application/json");
http.addHeader("X-AIO-Key", IO_KEY);
String message = "{\"value\": \"200\"}";
int httpCode = http.POST(message);// message);
if (httpCode > 0)
{
Serial.printf("[HTTP] POST... code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK)
{
String payload = http.getString();
Serial.println(payload);
}
}
else
{
Serial.println(httpCode);
Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();