mrwick:
Hi
I'm trying to post the below to my express js endpoint
I have a function below but it's posting an invalid JSON body to my express js.
Body
How do I correct this?
thanks
You should be using a JSON serializer.
#include <jason.mqh> void OnStart() { CJAVal json; json["key"] = "value"; Print(json.Serialize()); }
JSON Serialization and Deserialization (native MQL)
- www.mql5.com
ForecastOscilator_HTF The ForecastOscilator indicator with the timeframe selection option available in the input parameters. Flat_HTF The Flat indicator with the timeframe selection option available in the input parameters. FX5_SelfAdjustingRSI_HTF The...
You mean something like this? It's still show invalid body. Could you give me an example how I can do a POST on this?
void PostOrderStatusAPI(string pair, int order_type) { if(MQLInfoInteger(MQL_TESTER)) { } else { // JSON text to send // string strJsonText= "{\"key\"= \"value\"}; CJAVal json; json["key"] = "value"; // Text must be converted to a uchar array. Note that StringToCharArray() adds // a nul character to the end of the array unless the size/length parameter // is explicitly specified uchar jsonData[]; StringToCharArray(json.Serialize(), jsonData, 0, StringLen(json.Serialize()),CP_UTF8); // Use MT4's WebRequest() to send the JSON data to the server. char serverResult[]; string serverHeaders; int res = WebRequest("POST", "http://x.x.x.x/api/updatetradingstatus/", "", "", 10000, jsonData, ArraySize(jsonData), serverResult, serverHeaders); Print("Web request result: ", res, ", error: #", (res == -1 ? GetLastError() : 0)); } }
Dear nicholish en
would you please provide the code to de serialize this JSON URL?
i tried a lot but all with false results.
https://search.codal.ir/api/search/v2/q?&Audited=true&AuditorRef=-1&Category=-1&Childs=true&CompanyState=-1&CompanyType=-1&Consolidatable=true&IsNotAudited=false&Length=-1&LetterType=-1&Mains=true&NotAudited=true&NotConsolidatable=true&PageNumber=1&Publisher=false&TracingNo=-1&search=true
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
I'm trying to post the below to my express js endpoint
I have a function below but it's posting an invalid JSON body to my express js.
Body
How do I correct this?
thanks