Sending Excel file via post script.
-
wrote on 30 Mar 2017, 13:54 last edited by
Hi,
I want to send a excel file via post:QNetworkRequest request( QUrl( "my url") ); request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); QUrlQuery params; params.addQueryItem( "username", accountName ); params.addQueryItem( "file", reportFile->readAll() ); QNetworkAccessManager manager; QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
But I get the upload error .
The post script is tested and works fine.
Can anybody check if I do something wrong there?
Any hints would be priceless.Best regards,
Tomek -
Hi,
I want to send a excel file via post:QNetworkRequest request( QUrl( "my url") ); request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); QUrlQuery params; params.addQueryItem( "username", accountName ); params.addQueryItem( "file", reportFile->readAll() ); QNetworkAccessManager manager; QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
But I get the upload error .
The post script is tested and works fine.
Can anybody check if I do something wrong there?
Any hints would be priceless.Best regards,
Tomekwrote on 30 Mar 2017, 14:15 last edited by@Kaluss said in Sending Excel file via post script.:
params.addQueryItem( "file", reportFile->readAll() );
What is this supposed to do?! doesn't look right to me
-
wrote on 30 Mar 2017, 14:17 last edited by
Then how I should send file binary data?
-
Hi,
I want to send a excel file via post:QNetworkRequest request( QUrl( "my url") ); request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); QUrlQuery params; params.addQueryItem( "username", accountName ); params.addQueryItem( "file", reportFile->readAll() ); QNetworkAccessManager manager; QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
But I get the upload error .
The post script is tested and works fine.
Can anybody check if I do something wrong there?
Any hints would be priceless.Best regards,
Tomekwrote on 30 Mar 2017, 14:25 last edited by@Kaluss said in Sending Excel file via post script.:
The post script is tested and works fine.
Could you show us your script?
-
Hi,
I want to send a excel file via post:QNetworkRequest request( QUrl( "my url") ); request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); QUrlQuery params; params.addQueryItem( "username", accountName ); params.addQueryItem( "file", reportFile->readAll() ); QNetworkAccessManager manager; QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
But I get the upload error .
The post script is tested and works fine.
Can anybody check if I do something wrong there?
Any hints would be priceless.Best regards,
Tomek -
wrote on 3 Apr 2017, 09:01 last edited by
You are right, but I don't have any experience with multipart sending.
Could anybody give ma a hint how to prepare that?I have to send to parameters:
1)Username as a string
2)File as a binary dataHow to prepare particular parts?
BR/T
-
You are right, but I don't have any experience with multipart sending.
Could anybody give ma a hint how to prepare that?I have to send to parameters:
1)Username as a string
2)File as a binary dataHow to prepare particular parts?
BR/T
wrote on 3 Apr 2017, 11:21 last edited byJust have a look at the documentation at http://doc.qt.io/qt-5/qhttpmultipart.html
There is an example how to post data and file to a Web page
-
wrote on 4 Apr 2017, 07:03 last edited by
Documentation helped me a lot, but wireshark was also very helpful.
1/8