Hello,

I've been doing a lot of interfacing with Google Firebase over QNetworkAccessManager, and the only thing I have not been able to get working with this now is posting to the Realtime Database.

I have the following curl script that works (My project's url is hidden for obvious reasons)

Qt Code:
  1. curl -X POST -d '{"TIMESTAMP2" :{ "Sensor Name": "Test Sensor", "Event Name": "Test Event" } }' \
  2. 'https://HIDDEN.firebaseio.com/Notifications.json'
To copy to clipboard, switch view to plain text mode 

I am trying to replicate it within the QNetworkAccessManager and i've got the following to build / setup the code. I've had to cobble the sample code below together from a few abstracted values, but it should get the gist across.

Qt Code:
  1. _networkManager = new QNetworkAccessManager(this);
  2.  
  3. QVariantMap information;
  4. information.insert("Sensor Name", _sensorName);
  5. information.insert("Event Name", _eventName);
  6.  
  7. QVariantMap jsonMap;
  8. jsonMap.insert(_timeString, information);
  9.  
  10. QJsonDocument doc = QJsonDocument::fromVariant(QVariant(jsonMap));
  11. auto jsonString = doc.toJson();
  12.  
  13. QByteArray postDataSize = QByteArray::number(jsonString.size());
  14.  
  15. QNetworkRequest request("https://HIDDEN.firebaseio.com/Notifications.json");
  16.  
  17. request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
  18. request.setRawHeader("Content-Length", postDataSize);
  19. request.setRawHeader("Authorization", _gCloudata->WebKey);
  20.  
  21. QNetworkReply *reply = _networkManager->post(request, jsonString);
To copy to clipboard, switch view to plain text mode 

Now when the response comes back i'm printing both the headers and the error code (QNetworkReply::error()) and I am getting the following:

Qt Code:
  1. Reply receieved: ServerDateContent-TypeContent-LengthConnectionAccess-Control-Allow-OriginCache-ControlStrict-Transport-Security
  2. Network Error: 302
To copy to clipboard, switch view to plain text mode 
The top stuff is a complete and utter mystery, but the 302 error code is something that can be followed.
302 is the following: https://tools.ietf.org/html/rfc7231#section-6.3.4

When i do the curl script without the -X in front, i get something Similar:
Qt Code:
  1. curl: (6) Could not resolve host: POST
To copy to clipboard, switch view to plain text mode 



I am guessing the -X is the culprit to this WORKING in a curl command. So I guess my first question is how do I force the network request to run with this -X command?