Home > Mobile >  Fire base Update c / how to detect string in URL
Fire base Update c / how to detect string in URL

Time:07-27

I want to change some Data in my realtime firebase based on the id. I want to customize my Https but it does not work. when i add id to my URL i got a failure: QNetworkRequest newAdminRequest(QUrl("gymmanagment-a6c01-default-rtdb.europe-west1.firebasedatabase.a…" id)) –

void DatabaseHandler::AddAdmin(QString name, QString password, 
QString email, QString Geburtsdatum){
m_networkManager = new QNetworkAccessManager( this);

QVariantMap newAdmin;

newAdmin["Name"] = name;
newAdmin["Password"] = password;
newAdmin["Email"] = email;
QJsonDocument jsonDoc = QJsonDocument::fromVariant( newAdmin );
std::string id = "-N7pPxSHoPVlyEi8e0xW";
QNetworkRequest newAdminRequest(QUrl("https://gymmanagment-a6c01-default-rtdb.europe-west1.firebasedatabase.app/Admin.json"  id));

newAdminRequest.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json"));
m_networkManager->put(newAdminRequest, jsonDoc.toJson() );}

CodePudding user response:

You need to access the 'id' as if it were an 'endpoint', like this:

https://gymmanagment-a6c01-default-rtdb.europe-west1.firebasedatabase.app/Admin/-N7pPxSHoPVlyEi8e0xW.json

For general case, you can join each part:

QString id = "-N7pPxSHoPVlyEi8e0xW";
QString base = "https://gymmanagment-a6c01-default-rtdb.europe-west1.firebasedatabase.app/Admin/";
QUrl url = base   id   ".json";
yourRequest->setUrl(url);

Then, put your changes.

  • Related