webrequest remote file check error

 

hello

i want to check url existence.

but even though url exist it return error.

i really can't figure out what wrong with it..i think it correct code.

but still return error.

anyone guide me much appreciate thanks!

   string cookie=NULL,headers;
   char post[],result[];
   int res;
   string google_url="http://www.hongbopro.com/readme.html";
   ResetLastError();
   int timeout=5000; 
   res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
//--- Checking errors
   if(res==-1)
     {
      Print("Error in WebRequest. Error code  =",GetLastError());
     
     }
   else
     {
      Print("file exist");
     }
 
james272:

hello

i want to check url existence.

but even though url exist it return error.

i really can't figure out what wrong with it..i think it correct code.

but still return error.

anyone guide me much appreciate thanks!

What error ?
 

Have you added your website in the allowed urls list ?

 
Lorentzos Roussos:

Have you added your website in the allowed urls list ?

where should have to add allowed url list?

thanks!

 
Alain Verleyen:
What error ?

whether url is exist or not it return error.

http://www.hongbopro.com/readme.html this url is exist url but still error return
 
james272:

where should have to add allowed url list?

thanks!

in MT4 go to Tools > Options > ExpertAdvisors , check the "Allow WebRequest for Listed Url" and add the url in the list.

 
Lorentzos Roussos:

in MT4 go to Tools > Options > ExpertAdvisors , check the "Allow WebRequest for Listed Url" and add the url in the list.

unfortunetly it still same error return.

 
james272:

whether url is exist or not it return error.

I am asking you what is the error number !
 

Works fine for me. 

setup

void OnStart()
{
   string base_url   = "http://www.hongbopro.com";
   string endpoint   = "/readme.html";
   int timeout       = 5000; 
   string headers    = NULL;
   char  request[];
   char  response[];
   string response_headers = NULL;
   ResetLastError();
   int r = WebRequest(
      "GET",             // HTTP method 
      base_url + endpoint,// Full URL 
      headers,           // headers  
      timeout,           // timeout 
      request,           // the array of the HTTP message body 
      response,          // an array containing server response data 
      response_headers   // headers of server response 
   );
   
   if(r < 0)
      Alert(StringFormat("you forgot to whitelist %s, dummy", base_url));
   else if(r != 200)
      Alert(StringFormat("Error = ", GetLastError()));
   else
      Alert("SUCCESS!");
}
 
nicholi shen:

Works fine for me. 

thanks so much!

but it return  "you forgot to whitelist http://www.hongbopro.com, dummy"

i using FXopen and platform version is 4.00 Build 1090

i think this error is more related with my mt4 platform?

what platform you are using?

thanks!

 
james272:

thanks so much!

but it return  "you forgot to whitelist http://www.hongbopro.com, dummy"

i using FXopen and platform version is 4.00 Build 1090

i think this error is more related with my mt4 platform?

what platform you are using?

thanks!

MT4 and MT5. There is an issue with the way you are white-listing the domain. Make sure you only input the domain and do not include any endpoints. 

http://www.hongbopro.com //YES

http://www.hongbopro.com/something.html //NO!!!
Reason: