API Query POST URL With Secret Key

 

After a whole day of research, I can't find a simple example of a MQL4 code to make a POST API Call with the Secret Key.

I did see the documentation but there is nothing I found with the simple post api call to a url with the secret key.

https://docs.mql4.com/common/webrequest


Can someone please help?

WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
WebRequest - Common Functions - MQL4 Reference
 
chris_constant:

After a whole day of research, I can't find a simple example of a MQL4 code to make a POST API Call with the Secret Key.

I did see the documentation but there is nothing I found with the simple post api call to a url with the secret key.

https://docs.mql4.com/common/webrequest

Can someone please help?

That is because, what you need to research is the HTTP protocol, and not MQL code. The WebRequest() function simply sends HTTP "messages". It is up to you to know how to properly format the HTTP message.

Forum on trading, automated trading systems and testing trading strategies

How can i send cookie session from WebRequest?

Fernando Carreiro, 2016.06.06 00:31

Maybe you should first learn about the HTTP protocol and how it all works. The cookie session (or any other header) can be transferred back and forth via the "headers" and "result_headers" arguments/parameters:

You will have to parse "result_headers" in accordance with the HTTP Headers format in order to extract the cookie information (or other header information you may need). Then when submitting a new request you will have to build the "headers" parameter according to the HTTP rules.

Here are some helpful links to get you started:

Please, note that this is not really a MQL coding related issue and you should look for advice and help about HTTP on other forums dedicated to such matters.

Forum on trading, automated trading systems and testing trading strategies

Auto trading the news

Fernando Carreiro, 2016.09.02 00:18

You will have to collect that data from Websites that are offering those services (be they paid or free). You can use the function WebRequest() to obtain data from the web, but you will have to learn about HTTP, and depending on the API the website provides, you may also need to learn REST,  JSON or XML or even standard HTML. These web protocols are however beyond the scope of this forum, so for more information you will have to search the Internet. Here are some links to get you started:

Please note, that collecting and parsing Web data via an API, is not something for a beginner or newbie coder. It requires at least an intermediate level of coding knowledge and good understanding about web protocols.

I also suggest reading the following threads on here:

EDIT: There are also relevant entries in the Codebase that will be of interest to you (had you done a search):

NB! However, please note that WebRequest() only works in EA's and Scripts but not in Indicators.

Forum on trading, automated trading systems and testing trading strategies

Metatrader 4 to Binary.com

Fernando Carreiro, 2016.09.14 10:04

You must first set permissions on MetaTrader's Options in order to allow access to that website. Go to the "Tools->Options" (or Ctrl+O) and then go to the "Expert Advisors" tab. At the very end of those options, to will find and have to enable the "Allow WebRequest for the listed URL:" and then proceed to add the URL of the site.

NB! Also, depending on the data being retrieved, you may need to use the 2nd version of WebRequest as the first one is only valid for form data (Content-Type: application/x-www-form-urlencoded).

WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
WebRequest - Common Functions - MQL4 Reference
Reason: