Download of the News File fails: 404 Page not found

 

Hi,

since the last terminal update to 890 I do have several problems.

A serious one is that my tries to load the new-file of the week fails:

#import "wininet.dll"
   int InternetOpenUrlW(int,string,string,uint,uint,uint);
#import
  ...
  string strUrl = "http://www.forexfactory.com/ffcal_week_this.xml";
  string iAg = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)";
  int HttpOpen=InternetOpenW(iAg,0," "," ",0);
  uint x =     INTERNET_FLAG_NO_CACHE_WRITE 
             | INTERNET_FLAG_PRAGMA_NOCACHE
             | INTERNET_FLAG_RELOAD;   
  int HttpRequest = InternetOpenUrlW(HttpOpen,strUrl, NULL, 0, x, 0);
  ... // read the page
  if(HttpRequest>0) InternetCloseHandle(HttpRequest);
  if(HttpOpen>0) InternetCloseHandle(HttpOpen);

BTW the older version

InternetOpenUrlW(HttpOpen,strUrl, "0", 0, x, 0);

with "0" causes this error ERROR_HHTP_HEADER_NOT_FOUND. Now use NULL.

But even without this problem I get only the 404 Page not Found.

Anybody with an idea what to do?

 
int HttpOpen=InternetOpenW(iAg,0," "," ",0);
  1. Check your return codes. Not at the bottom but right there. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  2. Do you really expect anything but 404 with the URL: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)
  3. Why don't you use the built in WebRequest - MQL4 Documentation


     
 
WHRoeder:
  1. Check your return codes. Not at the bottom but right there. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  2. Do you really expect anything but 404 with the URL: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)
  3. Why don't you use the built in WebRequest - MQL4 Documentation

add 1: I do check the Windows return code of all of my internet call (I skipped them here) they are all the time 0 = no error. But this way I found this error:  ERROR_HHTP_HEADER_NOT_FOUND caused by "0"

add 2: I normally tried just " " as agent it makes no difference!

add 3: a) I haven't thought of it. b) I couldn't imagine why the old code should stop working? c) Do we have to re-write all our codes after every update?

c) your suggestion isn't better at all:

string GrabWeb2(string strUrl, string rawFile, int debug=0) {//>4
   string cookie=NULL,headers;
   char post[],result[];
   int res, timeout=5000;
   strUrl = "http://www.server4you.de/vserver/";
   res=WebRequest("GET",strUrl,cookie,NULL,timeout,post,0,result,headers);
   if (res < 0) { Alert("Error in WebRequest. Error code  =",GetLastError()," = 4060 ERR_FUNCTION_NOT_CONFIRMED" );
       return("");
   } 
   string ret = CharArrayToString(result,0,-1);
   return(ret);
}

res becomes -1 and the error code is 4060 =

4060

ERR_FUNCTION_NOT_CONFIRMED

Function is not allowed for call


What to do?

 
gooly:

4060

ERR_FUNCTION_NOT_CONFIRMED

Function is not allowed forcall


You have two different problems. The error #4060 means that the URL is not on the "Allow WebRequest..." list in MT4's Tools / Options. It will be unrelated to the earlier problem using WinInet.
 
jjc:
You have two different problems. The error #4060 means that the URL is not on the "Allow WebRequest..." list in MT4's Tools / Options. It will be unrelated to the earlier problem using WinInet.

You are right, but from my viewpoint none of the mt4 options to load an internet page works.

I wont it work - no matter how!

 

The service desk told me that I have to separately allow the servers which I want to access in Terminal -> Tools -> Option -> Expert Advisor.

And I changed in my Error-function the return string for the 4060 Error to "function not confirmed / url not in Termial-Options"

 
gooly:

You are right, but from my viewpoint none of the mt4 options to load an internet page works.

I wont it work - no matter how!

Retrieval of http://www.forexfactory.com/ffcal_week_this.xml works for me using WebRequest provided that the URL is added to the list in Tools / Options.

And your GrabWeb() code from https://forum.mql4.com/62321#941970 also works for me.