Wininet Doesn't Send Out HTTP Request

 
string query     = StringConcatenate("symbol=BTCUSDT&isIsolated=TRUE&timestamp=",(long)TimeGMT()*1000, "&signature=", signature);
string script    = StringConcatenate("sapi/v1/margin/openOrders?", query, "&signature=", signature);
string host      = "api.binance.com";
string header    = StringConcatenate("X-MBX-APIKEY:", ApiKey);
   
bool   res       = HttpDELETE(host, script, header);
if(res == false)
{
      Print(res); 
      Print(GetLastError());  
} else {
      Print("Success"); //This prints
}



bool HttpDELETE(string host, string script, string httpRequest)
{
  int hIntrn = InternetOpenW("", 0, "", "", 0);
  
  if (hIntrn == 0) {
    Print("itrn: false");
    return (false);
  }

  int hConn = InternetConnectW(hIntrn, host, "INTERNET_DEFAULT_HTTPS_PORT", "", "", 3, 0, 0);

  if (hConn == 0) {
    Print("hconn: false");
    return (false);
  }
  
  string Types = "";
  char acceptTypes[];
  StringToCharArray(Types, acceptTypes);

  int hReq = HttpOpenRequestW(hConn, "DELETE", script, "", "", acceptTypes, 0, 0);

  if (hReq == 0) {
      Print("hreq: false");
      return (false);
  }

  string data = "";
  if (!HttpSendRequestW(hReq, httpRequest, StringLen(httpRequest), data, StringLen(data))) {
    Print("lasterror: Send Request Error"); 
    return (false);
  }

  InternetCloseHandle(hReq);
  InternetCloseHandle(hConn);
  InternetCloseHandle(hIntrn);

  return (true);
}

I have imported Wininet and tried using it to send HTTP Delete. It seems that there is no error returned. However, on the server side the data was not being removed, which means the request is not successful.

 
vicknick:I have imported Wininet and tried using it to send HTTP Delete. It seems that there is no error returned. However, on the server side the data was not being removed, which means the request is not successful.
  • use a Proxy or Network analyser to see what is going on at the network level.
  • Program some C++ code to test see if it works properly at the WinAPI level.
  • Use MetaEditor debugger to debug the problem at the MQL level
Reason: