http post with mql4

 

Hello ,

Is it possible to send  HTTP POST request with JSON(application/json) as content type ?

I am trying to send HTTP Post request to an API, Please take a look at the code below :

   string url = "https://myurl.com/wp-json/ap/v1/signal?id=wervsdf&secret=lrjmsrbrh4sd4r45ert5";   
   string strJsonText = "{\"trade_type\": \"sell\",\"currency_pair\": \"USD/EUR\",\"status\": \"active\",\"signal\": {\"entry\": \"0.5555\",\"sl\" : \"0.5558\",\"tp1\": \"0.5556\",\"tp2\": \"0.5556\",\"tp3\": \"0.5557\"}}";

   uchar jsonData[];
   
   StringToCharArray(strJsonText, jsonData, 0, StringLen(strJsonText));
   
   char serverResult[];
   string type= "Content-Type: application/json";
   int res = WebRequest("POST", url, "", "", 10000, jsonData, ArraySize(jsonData), serverResult, type);
  
   Print(res);


Api Expects POST values as JSON and Content type as "application/json",  but when I run the above code , I get error 400 

Where am I making the mistake ?