So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By WillemR
#74207 Hi Guys
I spent the whole day struggling with an Exception 9 when I writeToStream(). This is a method in the HTTPClient library.
I can not see what I am doing wrong.
Maybe someone has some insight.

If I comment out the writeToStream line, there is no exception.

Look forward to hearing from you.


do
{
int httpCode = http.GET();
Serial.print("httpCode : ");
Serial.println(httpCode);
if (httpCode)
{
if (httpCode == 200)
{
String payload = http.getString();
Serial.println(payload);
fileRemain=http.getSize();
Serial.print("getSize : ");
Serial.println(fileRemain);

picFile=SD.open(filePath,FILE_WRITE);
sent=http.writeToStream(&picFile); //<----------------- PROBLEM IS HERE

Serial.print("Bytes: ");
Serial.println(sent);


picFile.close();

if(SD.exists(filePath))
{
Serial.println("File written !!!");
}
else
{
Serial.println("File NOT OK !!!");
}



break;
}
}
// delay(50);
}while(++count<10);





// Serial.println("closing connection");
http.end();
// WiFi.disconnect();
}