Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.12.8
-
None
Description
I have a QOAuth2AuthorizationCodeFlow (this->m_auth) and i want to use it to upload a file usingĀ a multipart/form-data HTTPS POST request.
Here is the important part of the call:
void MyClass::post_file_to_api(QUrl url, QFile* file, CallbackFunc callback){ QHttpMultiPart* multiPart = new QHttpMultiPart(QHttpMultiPart::ContentType::FormDataType, this); QHttpPart part; if(!file->open(QIODevice::ReadOnly)) { delete file; return; } part.setBodyDevice(file); file->setParent(multiPart); multiPart->append(part); multiPart->setContentType(QHttpMultiPart::ContentType::FormDataType); QNetworkReply* reply = this->m_auth->post(url, multiPart); this->connectCallback( reply, callback ); return; }
Other authenticated requests to the API work as expected, but this does not set the ContentType of the Request to "multipart/form-data" as promised by the documentation:
https://doc.qt.io/qt-5/qhttpmultipart.html#setContentType
https://doc.qt.io/qt-5/qhttpmultipart.html#ContentType-enum
The Captured HTTP Stream looks like this:
It can be seen, that the Content-Type is set to "application/x-www-form-urlencoded" which does confuse my backend.It looks like the QHttpMultipart::ContentType is somehow interpreted like a QAbstractOAuth::ContentType