-->
Page 1 of 1

ESP8266 301(moved permanently)

PostPosted: Sun Dec 13, 2020 2:29 pm
by Anonym
Sorry for bad english
My problem is literally same as
https://www.esp8266.com/viewtopic.php?f=160&t=21841,
but i can't solve my problems with responses of users. What i'm need to change?
Maybe, i'm translated responses wrong, but...
Code looks absolutely same
Link to a screenshot of my sheet
https://ibb.co/ctTtfpz
I censored WIFi information and the API key, so that's not what's causing the problem.
I'm trying to create a new record on Airtable using their API, from an ESP8266, but I keep getting error 301 (moved permanently).

Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
 
#define DEBUG_ESP_HTTP_CLIENT
 
const char* ssid = "WiFi name";
const char* password = "pssword";
 
void setup() {
 
 Serial.begin(115200);
 
 WiFi.mode(WIFI_STA);
 WiFi.begin(ssid, password);
 
 while (WiFi.status() != WL_CONNECTED) {
 delay(1000);
 Serial.println("Connecting to WiFi..");
 }
 
 Serial.println("Connected to the WiFi network");
 delay(1000);
}
 
void loop() {
 
 String data = "{\"fields\":{\"Name\":Plate1,\"MUSTTOWORK\":1,\"NEXTName\":Plate2}}";
 
 HTTPClient airtable;
 airtable.begin("sheet url");
 airtable.addHeader("Content-Type", "application/json");
 //airtable.addHeader("Authorization", "Bearer really cool api key");
 Serial.println("Sending HTTP Request");
 int httpResponseCode = airtable.POST(data);
 Serial.println("HTTP Request sent");
 if(httpResponseCode>0){
 String response = airtable.getString();
 
 Serial.println(httpResponseCode);
 Serial.println(response);
 }else{
 Serial.print("Error on sending POST Request: ");
 Serial.println(httpResponseCode);
 }
 
 airtable.end();
 
 delay(5000);
}

Re: ESP8266 301(moved permanently)

PostPosted: Wed Dec 16, 2020 3:59 am
by schufti
ok, so did you also read my comment in this thread?
the api is not reachable via http:// but gets redirected to https:// and the http:// client is not programmed to hadle redirects automatically....
maybe contact the author of the other thread how he solved it?