<div dir="ltr">Hi,<div><br>I am trying to submit google forms programmatically via C++ and Qt classes<br><br>I am basing my study on the following<br><br><a href="https://stackoverflow.com/questions/17964429/google-forms-response-with-python#17965510">https://stackoverflow.com/questions/17964429/google-forms-response-with-python#17965510</a><br><br>I got the Python version running and returned a 200 response.<br><br>I tried converting the code to C++ and Qt but was not successful. I get a response of '0' zero<br><br>I would like to know if I am using the Qt QNetwork classes correctly to submit a post to a URL that is a Google form<br><br>=============================================================<br>#include <QtNetwork/QNetworkRequest><br>#include <QtNetwork/QNetworkAccessManager><br>#include <QUrlQuery><br>#include <QDebug><br>#include <QNetworkReply><br><br>int main()<br>{<br><br>    QUrlQuery postData;<br>    postData.addQueryItem("emailAddress", "<a href="mailto:abc.xyz@gmail.com">abc.xyz@gmail.com</a>");<br>    postData.addQueryItem("entry.2020959411", "Qt Query");<br><br>    /*<br>     *<br>    url = '<a href="https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/formResponse">https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/formResponse</a>'<br>    form_data = {'entry.2020959411': '18+ sollte absolute Pflicht sein',<br>                 #'entry.2020959411': 'Alter sollte garkeine Rolle spielen',<br>                 #'entry.2020959411': '17+ wäre für mich vertretbar',<br>                 #'entry.2020959411': '16+ wäre für mich vertretbar',<br>                 #'entry.2020959411': '15+ wäre für mich vertretbar',<br>                 #'entry.2020959411': 'Ausnahmen von der Regel - Dafür?',<br>                 #'entry.2020959411': 'Ausnahmen von der Regel - Dagegen?',<br>                 #'entry.2020959411': '__other_option__',<br>                 #'entry.2020959411.other_option_response': 'test',<br>                 'draftResponse': [],<br>                 'pageHistory': 0}     *<br>     */<br><br>    QUrl serviceUrl("<a href="https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/formResponse">https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/formResponse</a>");<br><br>    // ...<br>    QNetworkRequest request(serviceUrl);<br>    //request.setHeader(QNetworkRequest::ContentTypeHeader,<br>    //    "application/x-www-form-urlencoded");<br>    QNetworkAccessManager networkManager;<br>    QNetworkReply* reply;<br>    reply = networkManager.post(request, postData.toString(QUrl::FullyEncoded).toUtf8());<br>    QVariant statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute );<br>    int status = statusCode.toInt();<br>    qDebug() << status;<br>    if ( status != 200 )<br>    {<br>        QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString();<br>        qDebug() << reason;<br>    }<br><br>   return 0;<br>}<br><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Nicholas Yue<br>Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5<br>Custom Dev - C++ porting, OSX, Linux, Windows<br><a href="http://au.linkedin.com/in/nicholasyue" target="_blank">http://au.linkedin.com/in/nicholasyue</a><br><a href="https://vimeo.com/channels/naiadtools" target="_blank">https://vimeo.com/channels/naiadtools</a><br></div></div></div></div>