I am using an ESP32 to make the POST below up to the SensorPush API using the Fetch for Arduino library.
#include "recipes/WiFi.h"
#include "Fetch.h"
void setup() {
Serial.begin(9600);
connectWiFi("<SSID>", "<PASSWORD>");
RequestOptions options;
options.method = "POST";
options.headers["accept"] = "application/json";
options.headers["Content-Type"] = "application/x-www-form-urlencoded";
options.body = "email=<EMAIL_ADDRESS>&password=<PASSWORD>";
Response response = fetch("https://api.sensorpush.com/api/v1/oauth/authorize", options);
// Printing response.
Serial.println(response);
}
void loop() {
}
The response I get back looks like this in the serial monitor:
{
"ok": 0
"status": 412
"statusText": "Precondition Failed"
"body": "{"message":"Must provide email or apiId"}"
}
I have tested this out using Insomnia and Postman where it seems to work just fine. I'm struggling to find a way to see what options looks like in Response response = fetch("https://api.sensorpush.com/api/v1/oauth/authorize", options) when it's actually sent over the wire.
I have a feeling that something about my BODY is getting lost. Whatever it is, it's driving me nuts!! ![]()