Hi Momin Khan
Probably got your answer, but for anyone out thier looking to do a "PUT" to firebase.
I have an array of pairs as a .mqh file for include.
#include <pairs.mqh> #include <Arrays\ArrayObj.mqh> #include <JAson.mqh> //--- parameters for receiving data from the terminal string url = "https://xxxxx.firebaseio.com/prices.json"; input ENUM_TIMEFRAMES timeFrame = PERIOD_D1;
I was getting a 400 response for a while but checked with postman and it was just the body json malformed when Serializing.
void postJson(ENUM_TIMEFRAMES tf) { int size = ArraySize(pairsList); CJAVal data; for(int i = size - 1; i >= 0; i--) { string p = pairsList[i]; data[i]["pair"] = p; data[i]["open"] = iOpen(p, tf, 0); data[i]["close"] = iClose(p, tf, 0); data[i]["value"] = (getPercentageChange(p, tf)); data[i]["updated"] = TimeToString(TimeCurrent()); } string prices = data.Serialize(); char serverResult[]; uchar da[]; StringToCharArray(prices, da, 0, StringLen(prices)); string serverHeaders = "content-type: application/json;\n"; int res = WebRequest("PUT", url, NULL, NULL, 1000, da, ArraySize(da), serverResult, serverHeaders); Print("Web request result: ", res, ", error: #", (res == -1 ? GetLastError() : 0)); }
We post the Auth section when done
Momin. Thanks for this example!
Comments that do not relate to this topic, have been moved to "Off Topic Posts".

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 am new to mql i am trying to update data in my firebase database. I successfully sent "POST" request but it appends to previous data and i want to update the previous data so i need to do "PUT" request. Here is my code.