Hello
I trying to connect to https script google site with Wio Terminal, but iit works every now and then
I have “HTTP Status Code: -7”.
See log
00:10:39.243 -> Reading Data From Google Sheet…
00:10:41.680 -> HTTP Status Code: 200
00:10:41.680 -> Payload: 10
00:10:42.664 -> Reading Data From Google Sheet…
00:10:44.493 -> HTTP Status Code: -7
00:10:44.493 -> Error on HTTP request
00:10:45.524 -> Pulsante 1
00:10:45.524 -> Reading Data From Google Sheet…
00:10:48.055 -> HTTP Status Code: -7
00:10:48.055 -> Error on HTTP request
00:10:48.946 -> Reading Data From Google Sheet…
00:10:51.524 -> HTTP Status Code: -7
00:10:51.524 -> Error on HTTP request
00:10:52.602 -> Reading Data From Google Sheet…
00:10:55.321 -> HTTP Status Code: -7
00:10:55.321 -> Error on HTTP request
00:10:56.680 -> https://script.google.com/macros/s/zzz/exec?pulsante=1
00:10:56.680 -> Reading Data From Google Sheet…
00:10:59.305 -> HTTP Status Code: 200
00:10:59.305 -> Payload: 10
my code
#include “rpcWiFi.h”
#include <HTTPClient.h>
[…]
HTTPClient http;
http.setTimeout(3000);
String url = “https://script.google.com/macros/s/” + GOOGLE_SCRIPT_ID + “/exec?pulsante=” + pulsante;
Serial.println(url);
Serial.println(“Reading Data From Google Sheet…”);
if (http.begin(client, url.c_str()),443) { // HTTPS client, url.c_str()
tft.drawString(“Connesso”, 70, 130);
//-----------------------------------------------------------------------------------
//Removes the error “302 Moved Temporarily Error”
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
//-----------------------------------------------------------------------------------
//Get the returning HTTP status code
int httpCode = http.GET();
Serial.print("HTTP Status Code: ");
Serial.println(httpCode);
//-----------------------------------------------------------------------------------
if (httpCode <= 0) {
Serial.println("Error on HTTP request");
http.end();
client.stop();
tft.drawString("Error on HTTP request", 70, 150);
return;
}
//-----------------------------------------------------------------------------------
//reading data comming from Google Sheet
String payload = http.getString();
Serial.println("Payload: " + payload);
tft.drawString("Payload: " + payload, 70, 150);
//-----------------------------------------------------------------------------------
if (httpCode == 200) {
Serial.println("Payload: " + payload);
}
//-------------------------------------------------------------------------------------
http.end();
} else {
Serial.printf("[HTTPS] Unable to connect\n");
}
client.stop();
}
thanks