Adafruit IO Webhooks - Post a value

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
JonasSvegland
 
Posts: 1
Joined: Sat Nov 19, 2016 1:36 pm

Adafruit IO Webhooks - Post a value

Post by JonasSvegland »

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

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();

User avatar
brubell
Learn User Page
 
Posts: 2017
Joined: Fri Jul 17, 2015 10:33 pm

Re: Adafruit IO Webhooks - Post a value

Post by brubell »

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

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”