Web request error 5203

 
#property copyright " ETA"
#property link      "https://www.METATRADER.com"
#property version   "1.00"



input string LICENSEKEY = "1736525"; 

int OnInit()
  {
  string url = "https://example.com/license.php";
  string headers;
  string cookie=NULL;
  
  
  char post[];
  string personallicense = LICENSEKEY;
  string postText = "license_no="+(LICENSEKEY);
  StringToCharArray(postText,post,0,WHOLE_ARRAY,CP_UTF8);
  
  
  char result[];
  string resultHeaders;
  int response=WebRequest("POST",url,cookie,headers,1000,post,0,result,resultHeaders);
  
  Print(__FUNCTION__," > Server Response Is ",response," and the error is ",GetLastError());
  string resultText = CharArrayToString(result);
  Print(__FUNCTION__," > ",CharArrayToString(result));
  
  if(response==-1) 
     { 
      Print("Error in WebRequest. Error code  =",GetLastError()); 
      MessageBox("Add the address 'example.com' to the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION); 
     } 
  
  





   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+

Hi I'm trying to send a webrequest, but it says error code: 5203

I searched so much on the internet but i couldn't find something that resloves this. I added the "http://localhost" permission on the setting, but it's not the problem.

It doesn't work neither with GET, or POST


I have already added the api_url to the list of allowed URLs in the configuration.


Can anyone spot where is the error please?

 
Jolly Kaweesi:

Hi I'm trying to send a webrequest, but it says error code: 5203

I searched so much on the internet but i couldn't find something that resloves this. I added the "http://localhost" permission on the setting, but it's not the problem.

It doesn't work neither with GET, or POST


I have already added the api_url to the list of allowed URLs in the configuration.


Can anyone spot where is the error please?

I suggest you check with the Web servers logs...

It's impossible to tell with only one half/side of the code.

Also, print out the parameters to WebRequest, such that you can reconstruct the request with a tool like curl or with a browser and the dev console.

Then make your web server log all requests.

This way you might find out what's going on.

Usually it's a malformed request that you are sending.