0

Adafruit IO Webhooks - Post a value
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit IO Webhooks - Post a value

by JonasSvegland on Tue Apr 23, 2019 6:19 am

Hi!

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 | TOGGLE FULL SIZE
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();

JonasSvegland
 
Posts: 1
Joined: Sat Nov 19, 2016 1:36 pm

Re: Adafruit IO Webhooks - Post a value

by brubell on Thu Apr 25, 2019 9:51 am

You might want to try a raw webhook. Append /raw to the end of your webhook URL.

brubell
 
Posts: 471
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.