Post request from ESP8266 to Xano database

Options
bellwoodsweb
bellwoodsweb Member
edited October 2023 in ? Working with APIs

I'm trying to post data into a database table from my IOT device but I keep getting a 308 redirect response. Does anyone have experience with this?

Some of my code:
WiFiClient client;

HTTPClient http;

String serverPath = serverName + "/checklist_devices/";

http.begin(client, serverPath.c_str());

int httpResponseCode = http.GET();

Response:

Best Answer

  • bellwoodsweb
    bellwoodsweb Member
    Answer ✓
    Options

    Yeah I got it working.

    I'm working in C++ using PlatformIO. I used the ESP8266 WifiClientSecure library (previously I was trying regular WifiClient). The trick was the line client.setInsecure(). I'll have to go back and figure ssl certificates eventually but for now this works great.

    FYI, the variables "host" and "data" are type "String"

    Thanks for your help and quick responses Chris!

Answers

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    My first thought is that there is an issue with the request URL. Are you able to provide the full URL? If you don't want to share it here, feel free to reach out to us via support chat!

  • bellwoodsweb
    bellwoodsweb Member
    edited October 2023
    Options

    Seems to be an issue with sending requests via HTTP. I guess it needs secure requests via HTTPS

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Yes, that is correct — all requests need to be sent via HTTPS. Are you able to accommodate this with the IOT device in question? If not, there is probably a world where you could proxy requests through a server you control which would allow for making unsecured requests.