Reputation: 21
this is my code I am trying to send a PUT http request to this endpoint but Im getting error 4051 and also status code is -1 and it is not even reaching to the server.
void OnStart(){
double equity = AccountInfoDouble(ACCOUNT_EQUITY);
Alert("equity: ",equity);
Alert("INIT_SUCCEEDED: ",INIT_SUCCEEDED);
char post[], result[];
string headers ;
string obj = "{\"balance\":200000,\"minimumBalance\":200000,\"equity\":200000,\"minimumEquity\":200000,\"dateTime\":\"2023-01-15T23:45:00.000Z\"}";
StringToCharArray( obj, post, 0, StringLen(obj) ); // Must specify string length;
int res = WebRequest( "PUT",
"http://localhost:8000/api/user/add-equity-balance/1",
"",
NULL,
10000,
post,
ArraySize( post ),
result,
headers
);
Alert( "Status code: " , res, ", error: ", GetLastError() );
Alert( "Server response: ", CharArrayToString( result ) );
Alert("Server headers: ", headers);
}
I just need to send this PUT request
Upvotes: 1
Views: 461
Reputation: 70
//+------------------------------------------------------------------+
//| aads.mq4 |
//| Copyright 2023, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
input string mesaj="deneme";
input string sunucuAdres="http://deneme.ipekbilgisayar.org"; //Internet Adres
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
CagriGonder(mesaj);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CagriGonder(string Mesaj)
{
string cookie=NULL,headers;
char post[],result[];
string header="Content-Type: application/text";
StringToCharArray(Mesaj,post,0,StringLen(Mesaj));
ResetLastError();
int timeout=20000;
int res=WebRequest("POST",sunucuAdres,header,timeout,post,result,headers);
Print(CharArrayToString(result));
}
//+------------------------------------------------------------------+
Example
Upvotes: 1