I am a newbie in Arduino and IoT and using M5StickC Plus2 on Arduino IDE.
I am trying to push data to Prometheus pushgateway, but only get 400 response code. Pushgateway only accepts binary data. Everything works fine if I do it through curl. Here is my code:
#include <WiFi.h>
#include <HTTPClient.h>
WiFiClient client;
HTTPClient http;
bool httpOK = http.begin(client, "192.168.0.63", 9091, "/metrics/job/pushgateway-orangepi");
if(httpOK) {
String msg = String("temperatura{local=\"bsb\"} 24.12\n");
http.addHeader("Content-Type", "application/octet-stream");
http.addHeader("Content-Length", String(msg.length()));
int httpResponseCode = http.POST(msg);
http.end();
}