2

I've already used the native WebRequest() function to POST data.

Usually I post data using these lines below

// ********** 

char dataUpdatePost[]; 
char dataUpdateResult[];
string dataUpdateStr = "dataUpdateFlag=YES&orderNumber=" + orderNumber + "&profit=" + profit + "&profitPips=" + profitPips + "&cookie=" + sessionID;

ArrayResize(dataUpdatePost, StringToCharArray(dat[0,1], dataUpdatePost, 0, WHOLE_ARRAY, CP_UTF8) - 1);

ResetLastError();

int updateDataRes = WebRequest( "POST", 
                                "http://service.jumpinvestor.com/",
                                "",
                                NULL,
                                1,
                                dataUpdatePost,
                                0,
                                dataUpdateResult,
                                dataUpdateHeaders
                                );
// **********  

and it works fine ...

but this I would like to send an array like this.

string dat[3][10]; 

Is there a way in MQL4 to send it via WebRequest()?

Thank you in advance.

user3666197
  • 1
  • 6
  • 50
  • 92
nadstation
  • 23
  • 5

2 Answers2

1

JSON: The best way is to convert (serialize) your array into a JSON string, and send it over, with the WebRequest(). JSON is widely accepted format and chances are your web-application is able to parse (deserialize) them out of the box.

The downside is that you will need to write a serializer for it.
So far, I've only come across one MQL4 serializer:
https://www.mql5.com/en/code/11134

Good luck!

user3666197
  • 1
  • 6
  • 50
  • 92
jlee88my
  • 2,935
  • 21
  • 28
-1

Yes, there is

The universal approach is to write your Domain-specific wrapper,
that would provide translation from string dat[3][10] array-cells into a string.


A just-enough design = a domain specific SER/DES wrapper:

In MQL4 / python-AI/ML distributed processing grid-computing a following trivial message-passing syntax shows a possible way ( sure, could be a binary-efficient package, but neither a performance or the message size-overhead is an issue, as the CPU-bound AI/ML process represents the major latency factor ) :

A "JUST-ENOUGH-DESIGN"

MINIMALISTIC
SERialiser       on MT4   side: fast, CPU/RAM efficient, loss-less
DESerialiser     on .recv side: fast & unambiguous binary/ASCII DES-erialisation

HERE: SER-ialiser
         - byte-aligns data in ASCII uchar-s
         - adds Section + EoLN separators
         - adds Item + ValItem separators
         - sends plain ASCII string across the network ---> (ref. ROWs below)

+------------------------------------------------------------------------------------------ aSectionSEPARATOR ( no CrLf ambiguity in MT4/UNICODE string / StringSplit( string, ushort, ... ) )
|                +----------------------------------+----------------------------------+--- aLevTpSlSEPARATOR { ... o ... o ... o ... }[0..3]
|               0|                                 1|                                2 |  3
|                |                                  |                     +------------|--- aValItemSEPARATOR { ... | ... | ... | ... }[0..2,3]
|                |                                  |                     |            |
|           0:1:2|   :     :           :            |   :     :           v            |+-- expEoLN_SEPARATOR
|            : : |  0:    1:          2:           3|   :     :           :            ||
v            : : v   :     :           :            v  0:    1:          2:          3 vv
/\/\/\/\/\/\/:\:/|\/\:/\/\/:\/\/\/\/\/\:/\/\/\/\/\/\|/\/:\/\/\:/\/\/\/\/\/|\/\/\/\/\/\/|*
_  1192.39001|+| o--^| 1.52|    4.57070|    3.00752 o--v| 0.31|    1.80752|    5.77070 o*
_  1186.39001|+| o--^| 1.31|    4.09104|    3.11518 o--v| 0.36|    1.91518|    5.29104 o*

Even a JSON-compatible "rich-format-wrapped" data could be sent ...

This way WebRequest() can send JSON-alike formatted strings towards remote processing at your will.


Anyway

Enjoy the MQL4 worlds.

user3666197
  • 1
  • 6
  • 50
  • 92