Does WebRequest have DELETE function

 

I am trying to use DELETE method for WebRequest function, but it seems to always return error -1. There are not much discussion about this issue after some searching, besides using some windows function as workaround? Some suggest X-HTTP-method-override: DELETE but I don't think that works.

Just want to confirm if it doesn't support DELETE, and what's the usual workaround for this issue. 

Documentation on MQL5: Network Functions / WebRequest
Documentation on MQL5: Network Functions / WebRequest
  • www.mql5.com
WebRequest - Network Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
vicknick: I am trying to use DELETE method for WebRequest function, but it seems to always return error -1. There are not much discussion about this issue after some searching, besides using some windows function as workaround? Some suggest X-HTTP-method-override: DELETE but I don't think that works. Just want to confirm if it doesn't support DELETE, and what's the usual workaround for this issue. 

I don't believe that there is such a limitation on the HTTP method parameter.

What is the error code being returned?

 
Fernando Carreiro #:

I don't believe that there is such a limitation on the HTTP method parameter.

What is the error code being returned?

int    res       = WebRequest("DELETE",url,header,0,post,result,str);
if(res != 200)
{
      Print("rescode:",res); //This print -1
} else { 
      Print("Success");
}
It just gives -1. Everything for the headers and inputs are correct. If I change to "POST" then it works, but obviously I want "DELETE" for this case since the service I am using specify DELETE to remove data.
 

vicknick #: It just gives -1. Everything for the headers and inputs are correct. If I change to "POST" then it works, but obviously I want "DELETE" for this case since the service I am using specify DELETE to remove data.

I will repeat my question! What was the error code?

If you not checking, then how will you know the cause?

GetLastError

Returns the last error

Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL4 Reference
Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL4 Reference
 
Fernando Carreiro #:

I will repeat my question! What was the error code?

If you not checking, then how will you know the cause?

GetLastError

Returns the last error

The error is 

4051

ERR_INVALID_FUNCTION_PARAMVALUE

Invalid function parameter value

 
vicknick #: The error is 4051

ERR_INVALID_FUNCTION_PARAMVALUE

Invalid function parameter value

Then maybe it is indeed rejecting "DELETE".

Have you tried other methods to see which ones are accepted and which ones are rejected, namely DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH, TRACE?

 
Fernando Carreiro #:

Then maybe it is indeed rejecting "DELETE".

Have you tried other methods to see which ones are accepted and which ones are rejected, namely DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH, TRACE?

GET and POST works fine. I am not sure about other methods, have to use DELETE only because of what the API I am using specified. Do you know any workaround on this?
 
vicknick #: GET and POST works fine. I am not sure about other methods, have to use DELETE only because of what the API I am using specified. Do you know any workaround on this?

You did mention "X-HTTP-Method-Override" ( or " X-Method-Override " ). Did you try it or did you just presume that it would fail?

According to what I found in a Google search, Binance has reinstated support for it after it was removed some time back. So it should work now.

... this should now be fixed in production. Could you try using X-HTTP-Method-Override and let us know if it’s working like it was before?
Just made a test. It seems that is is working!! Thank You guys so much.
Removed support for X-HTTP-Method-Override causes my bots to stop working
Removed support for X-HTTP-Method-Override causes my bots to stop working
  • 2020.07.16
  • angree
  • dev.binance.vision
Binance just stripped the support for override method, that helped bypassing limitations of inability to send DELETE commands on my trading platform. The method i was using for 2 years was to use POST method, but to add to the HEADER: “\r\nX-HTTP-Method-Override: DELETE” This is widely accepted standard, but for at least 6 days it was stripped...
 
Fernando Carreiro #:

You did mention "X-HTTP-Method-Override" ( or " X-Method-Override " ). Did you try it or did you just presume that it would fail?

According to what I found in a Google search, Binance has reinstated support for it after it was removed some time back. So it should work now.

I tried both X-HTTP-Method-Override and X-Method-Override in the header, but doesn't work. The server returns 404 "Request method 'POST' not supported".

 
vicknick #:I tried both X-HTTP-Method-Override and X-Method-Override in the header, but doesn't work. The server returns 404 "Request method 'POST' not supported".
Then contact Binance and ask them about it. I gave you a link so follow it up with them.
 
There are several Market products offering Binance library functions and utilities, proving that it can be done with pure MQL code.
Reason: