Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By sadiq1aziz
#81010 Hi there

I need help urgently.

I tried to access JSON text on a HTTPS URL. Can't do so on HTTP. I used the template code in the examples section of the Arduino IDE file tab (ESP8266WiFi- HTTPSREQUEST).
i use client.readStringUntil(\n); to read the text.

After execution, it takes a while to get the text response. And when i do, part of the JSON text gets printed in the Serial monitor, followed quite shortly by a soft WDT reset.

I get some stack dump, and then it hangs...

Here is the header i get

X-Authentication-Time: 1ms
Cache-Control: max-age=60
Expires: Sun, 10 Mar 2019 12:53:54 +0000
X-Content-Type-Options: nosniff
X-Response-Time: 141.798ms
Vary: Accept-Encoding

If anyone has a proper functional template to read JSON text from a HTTPS URL via GET request , please post it below. I'd greatly appreciate your help!
User avatar
By RichardS
#81025 Seen this happen where the response is too long and it will not print correctly...

take the response and in a loop print out one character at a time to make sure...

char *p = response;
while(*p) {
Serial.print(*p++);
delay(0);
}
User avatar
By sadiq1aziz
#81032
RichardS wrote:Seen this happen where the response is too long and it will not print correctly...

take the response and in a loop print out one character at a time to make sure...

char *p = response;
while(*p) {
Serial.print(*p++);
delay(0);
}



You're right!

I fiddled about the code for a while after making this post and then decided to use a while loop with a break statement to execute the function to read string. Turns out it worked! It then dawned on me that the JSON data had to be read a character at a time to ensure that only the intended part of the JSON text and not the whole data dump was read until the terminating character. What happened earlier was that the "readStringUntil" function would overshoot the terminating character, attempt to read the whole JSON text only to hang with a WDTsoft reset. Glad to be rid of this problem!

Many thanks for your suggestion :)