Problem in using WebRequest in MQL5....

 

Hi all I am having problem in using WebRequest in MQL5....... I have also added web site's url in (Main Menu->Tools->Options, tab "Expert Advisors")  under "Allow WebRequest for listed URL" uption.


while calling WebRequest method EA returns error code = 4014


following in my code.... 

bool downloadNews(string date) 
{  
   //--------------------URL Format------------------------//
   //https://www.forexfactory.com/calendar.php?day=dec27.2018
   //--------------------URL Format------------------------//
   Print("******************************" + 1);
   bool result = false;
   ArrayFree(news);
   string cookie = NULL, result_headers;
   string headers = "text/html; charset=ISO-8859-1";
   char   data[];
   char result_data[];
   string url = "https://www.forexfactory.com/calendar.php?day=dec27.2018";
   //--- To enable access to the server, you should add URL "https://finance.yahoo.com" 
   //--- to the list of allowed URLs (Main Menu->Tools->Options, tab "Expert Advisors"): 
   
   Print("******************************" + 2);
   
   //--- Resetting the last error code 
   ResetLastError(); 
   
   Print("******************************" + 3);
   //--- Downloading a html page from Yahoo Finance 
   int res = WebRequest("GET", url, headers, 500, data, result_data, result_headers);
   Print(url);
   Print("******************************" + 4);
   if(res == -1) 
   { 
      Print("Error in WebRequest. Error code  =",GetLastError()); 
      //--- Perhaps the URL is not listed, display a message about the necessity to add the address 
      MessageBox("Add the address '"+url+"' to the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
      result = false;
   } 
   else 
   { 
      Print("******************************" + 5);
      if(res == 200) 
      { 
         //--- Successful download 
         PrintFormat("The file has been successfully downloaded, File size %d byte.",ArraySize(news)); 
         //PrintFormat("Server headers: %s",headers); 
         //--- Saving the data to a file 
         int filehandle=FileOpen("url.htm",FILE_WRITE|FILE_BIN); 
         
         if(filehandle!=INVALID_HANDLE) 
         { 
            //--- Saving the contents of the result[] array to a file 
            FileWriteArray(filehandle,result_data,0,ArraySize(result_data)); 
            
            Print("file size:   " + ArraySize(result_data));
            //--- Closing the file 
            FileClose(filehandle);
            result = true;
         } 
         else 
         {
            Print("Error in FileOpen. Error code =",GetLastError()); 
            result = false;
         }
      } 
      else 
      {
         PrintFormat("Downloading '%s' failed, error code %d",url,res); 
         result = false;
      }
   } 
   
   return result;
}


please help me.

 

How did you test this?
I think mostly you received this error on TESTER.

As i know in MQL5 you couldn't get respond of web request from tester. but i works on live trading (demo or live account doesn't matter)

I don't know why its not working and what is the logic behind it.

Reason: