Loading...
 

Generic Response

Response structure

Every call to a function of a MetaTrader messaging module of your choice will return a generic response in JSON format (implemented as a MQL string type) that will have this structure:

TypeNameDescription
boolisSuccessIndicates if the operation ended successfully or not. If 'false' is returned, the content field is an error entity (see below).
stringcorrelationKey(optional) Holds an identifier for the result of an background thread of a non-awaited call to a module (see the 
difference between awaited and non-awaited results).
genericcontent(optional) Depending on the payload an operation returns the content type differs. E. g.: It could be a
Telegram Message entity if you call a MQL Telegram function.

Response examples of successful requests

Successful response that contains a Telegram User Entity:

{"isSuccess":true,"content":{"id":112141350,"is_bot":true,"first_name":"MQL Bot","username":"mqlbot"}}


Successful response of a "Start" method that contains a correlation key:

{"isSuccess":true,"correlationKey":"HZ5PQI-0HLPLM9E6680A"}

 

Error structure

If an operation was not successful the content of the response is a error:

TypeNameDescription
stringmessageA less generic version of the exceptionMessage.
stringexceptionMessage(optional) Only available if SetDebugOutput is set to true (see API doc). Tells you specificly what went wrong.
stringexceptionType(optional) Only available if SetDebugOutput is set to true (see API doc). Tells you more about the exception type (e.g. ArgumentException if there was a problem with the arguments you provided for the called operation).
stringstackTrace(optional) Only available if SetDebugOutput is set to true (see API doc). Contains the stack trace of the operation. Can be used to report problems more specific.

Response examples of unsuccessful requests

Unsuccessful response of a method:

{"isSuccess":false,"content":{"message":"An exception occured."}}