Error 4051 in WebRequest

 

Hi.

I have this piece of code exactly copied as is from MQL4 documentation:

 

   string cookie=NULL,headers;

   char post[],result[];

   int res;

//--- for working with server you need to add "https://www.google.com/finance" 

//--- to the list of the allowed URLs (Main menu->Tools->Options, "Expert Advisors" tab)

   string google_url="http://www.google.es";

   

//--- reset last error

   ResetLastError();

//--- load html page from Google Finance

   res = WebRequest("GET",google_url,cookie,NULL,50,post,0,result,headers);

//--- check errors

   if(res==-1)

     {

      Print("Error code =",GetLastError());

      //--- maybe the URL is not added, show message to add it

      MessageBox("Add address '"+google_url+"' in Expert Advisors tab of the Options window","Error",MB_ICONINFORMATION);

     }

 

Why is MT4 returning me an 4051 error code????

 

Thank you! 

 

Yes I do: Invalid function parameter value.

The point here is that both the function prototype and MQL4 documentation says the same, and I've copied the code into my EA (and I've put that address in the Tools => Options => EA section too, but I'm still getting that 4051 error...

 Any help, please? 

 

Have you read in the Reference: "To be able to use the WebRequest function, you must add an URL to the list of allowed URLs in the "Expert Advisors" tab of the "Options" window." ?

 
Of course. That's what I've written in my previous post.
 
have you tried another url like the one from the reference? One of the "parameter value(s)" must be wrong!
 

Yes, I have tried many urls... and nothing works. I'm checking the parameters and I've tried many other things without success...

By the way: I'm working behind a proxy (which is correctly configured in my MT4). Could this be the reason for the problem? 

 

May be? Can you vary this configuration?

BTW I am using Windows-functions.

 

It is!!!!

I've run my code into a non-proxy Metatrader4 and it works!!!!

So I think we've got a bug here, havent' we?

gooly, how are you using those Windows-functions?

Thanks a lot! 

 

hmm, google for "wininet.dll", InternetOpenW(..) mt4 mql4.

It should give you lots of examples.

 

Thank so much.

 I'll have a look.