Sending WebRequest with certain data format

 

I know how to send a POST Request in MQL5 and how to pass the data


but I would like to send the body with a certain format

what I mean , I have these values


int x = 0;

int y = 1;


I would like to have the body in this format (you know the REST API accept JSON body)

{

    "singalData" : {

             "x" : 0,

             "y" : 1

    }

}


how to convert from these variables to this format ?

 
Ahmed Mohsen:

I know how to send a POST Request in MQL5 and how to pass the data


but I would like to send the body with a certain format

what I mean , I have these values


int x = 0;

int y = 1;


I would like to have the body in this format (you know the REST API accept JSON body)

{

    "singalData" : {

             "x" : 0,

             "y" : 1

    }

}


how to convert from these variables to this format ?

https://www.mql5.com/en/code/13663?utm_campaign=codebase.list&utm_medium=special&utm_source=mt5editor

#include <jason.mqh>

void OnStart() {
   int x = 1;
   int y = 2;
   CJAVal json;
   json["singalData"]["x"] = x;
   json["singalData"]["y"] = y;
   Print(json.Serialize());
}
//{"singalData":{"x":1,"y":2}}

JSON Serialization and Deserialization (native MQL)
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 FX5_SelfAdjustingRSI...
 

your code helped , but there's something

the data attribute in WebService accept only const char data

so it says : 'WebRequest' - no one of the overloads can be applied to the function call"

 
Ahmed Mohsen:

your code helped , but there's something

the data attribute in WebService accept only const char data

so it says : 'WebRequest' - no one of the overloads can be applied to the function call"

Show your code, there might be a syntax error.

Reason: