http.getString

alemg77
Posts: 4
Joined: Fri Apr 06, 2018 3:53 pm

http.getString

Postby alemg77 » Fri Apr 06, 2018 5:24 pm

I am using the ESP-WROOM-32 module programming with Arduino in windows.

I want to get the Token ID of Firebase to connect, I do the POST, the server responds to me ok, but when I want to read the answer the program hangs and stops executing more code.

#include <WiFiClientSecure.h>
#include <HTTPClient.h>

const char* ssid = "...";
const char* password = "...";

void setup()
{
Serial.begin(115200);
delay(10);

// We start by connecting to a WiFi network
Serial.println();
Serial.println("************* Firebase_token3 *****************");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

void loop()
{
HTTPClient http;
Serial.println("[HTTP] Iniciando...\n");
http.begin("https://www.googleapis.com/identitytool ... sword?key=......");
http.addHeader("HOST","www.googleapis.com");
http.addHeader("Content-Length","82");
http.addHeader("Content-Type","application/json");
int httpCode = http.POST("{\"email\":\"...@....\",\"password\":\"......\",\"returnSecureToken\":true}");

if ( httpCode > 0 )
{
Serial.print("Codigo: ");
Serial.println(httpCode); // Up here all right, I can see 200 in the console
String respuesta = http.getString();
Serial.println(respuesta); // This line of code is never executed
Serial.println("Exito?");
}
else
{
Serial.println("Error comunicacion HTTP.... ");
}
http.end();
delay(5000);
}

ThomasW69
Posts: 4
Joined: Thu Oct 18, 2018 11:49 am

Re: http.getString

Postby ThomasW69 » Mon Nov 19, 2018 9:41 am

I have the same issue but nos solution yet.
Since the problem seems to have existed for quite some time, but no solution has been published yet, I assume that there is no interest in a solution.

uhleymann
Posts: 1
Joined: Mon Apr 01, 2019 2:24 pm

Re: http.getString

Postby uhleymann » Mon Apr 01, 2019 2:39 pm

I have the same problem with an ESP8266 in the same place in the code. The problem with me is, if the server responds with 200, the response payload e.g. due to network problems does not arrive at the client. In my application currently only a restart of the ESP helps. I would also be interested in another solution.

Who is online

Users browsing this forum: No registered users and 20 guests