I managed to make a very basic connection via https to an app. Here is the script i used, which is a generic one from Arduino IDEthat i modified slightly:
/*
HTTP over TLS (HTTPS) example sketch
This example demonstrates how to use
WiFiClientSecure class to access HTTPS API.
We fetch and display the status of
esp8266/Arduino project continuous integration
build.
Limitations:
only RSA certificates
no support of Perfect Forward Secrecy (PFS)
TLSv1.2 is supported since version 2.4.0-rc1
Created by Ivan Grokhotkov, 2015.
This example is in public domain.
*/
#define USING_AXTLS
#include <ESP8266WiFi.h>
// force use of AxTLS (BearSSL is now default)
#include <WiFiClientSecureAxTLS.h>
using namespace axTLS;
#ifndef STASSID
#define STASSID ""
#define STAPSK ""
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "esp8266nodemcu.bubbleapps.io";
const int httpsPort = 443;
void setup() {
Serial.begin(9600);
Serial.println();
Serial.print("connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Use WiFiClientSecure class to create TLS connection
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
WiFiClientSecure client;
#pragma GCC diagnostic pop
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
return;
}
String url = "/version-test/api/1.1/wf/esp8266";
Serial.print("requesting URL: ");
Serial.println(url);
client.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Authorization: Bearer 756490c40b8f6585a297c98b4d7385dd\r\n" +
"key1: test " + "\r\n" +
"User-Agent: BuildFailureDetectorESP8266\r\n" +
"Connection: close\r\n\r\n"
);
Serial.println("request sent");
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
String line = client.readStringUntil('\n');
if (line.startsWith("{\"state\":\"success\"")) {
Serial.println("esp8266/Arduino CI successfull!");
} else {
Serial.println("esp8266/Arduino CI has failed");
}
Serial.println("reply was:");
Serial.println("==========");
Serial.println(line);
Serial.println("==========");
Serial.println("closing connection");
}
void loop() {
}
I created an app just for testing, and it actually works. I hooked it up to the endpoint like you said and send an email whenever there is a post request:
here is the API endpoint in bubble:
However, i would like to send data in the POST request as well, but am not sure how to add that in the header?
Another concern i have is adding authorization. I am not good enough at C/C++ yet. But do you maybe know how to?
Here is a picture of my setup right now, powered by a AA battery pack (judge all you want
)