You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
philman
5 years agoExplorer | Level 4
Unknown error on upload
Dear support,
I would like to upload files to my Dropbox Application via Qt in c++ but it returns "unknown error" despite the "curl -X POST" equivalent is working like a charm in CLI mode.
Do you what is wrong?
Here the code in QT Creator I wrote:
dropbox.h
#ifndef DROPBOX_H #define DROPBOX_H #include <QObject> #include <QtNetwork/QNetworkAccessManager> class DropBox : public QNetworkAccessManager { Q_OBJECT public: explicit DropBox(QObject *parent = nullptr) : QNetworkAccessManager(parent) {} void upload(const QString filename); signals: public slots: private: }; #endif // DROPBOX_H
dropbox.cpp
#include "dropbox.h" #include <QFile> #include <QNetworkReply> void DropBox::upload(const QString filename) { QNetworkRequest request(QUrl("https://content.dropboxapi.com/2/files/upload")); request.setRawHeader(QByteArray("Authorization"), QByteArray("Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); QString dropboxArg = QString("{\"path\": \"/mouvdetect/QtHumanDetector/%1\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}").arg(filename); request.setRawHeader(QByteArray("Dropbox-API-Arg"), dropboxArg.toUtf8()); request.setRawHeader(QByteArray("Content-Type"), QByteArray("application/octet-stream")); QFile *file = new QFile(filename); file->open(QIODevice::ReadOnly); QByteArray content = file->readAll(); request.setRawHeader(QByteArray("Content-Length"), QByteArray::number(content.size())); QNetworkReply *reply = this->post(request, content); QObject::connect(reply, &QNetworkReply::finished, [=](){ QString err = reply->errorString(); QString contents = QString::fromUtf8(reply->readAll()); qInfo() << "Error:" << err;}); }
In the above code, please replace the automatic emoji with "opening bracket equal sign closing bracket"
Please tell me if you need more information on how to compile and run this code with Qt Creator.
Best regards,
Philman
- Greg-DBDropbox Staff
I don't believe the "unknown error" message is coming from Dropbox itself, so it's likely coming from the client you're using. We can't provide support for the client itself though, as it's not made by Dropbox.
Can you enable any extra logging or verbose mode though? If the Dropbox API request itself is failing, the Dropbox API HTTPS response would contain a more helpful error message.
- philmanExplorer | Level 4
Thank you Greg, for your prompt answer.
In fact, the message "unknown error" was thrown even if the file was well uploaded (so I was confused and I didn't check before if the file was effectively uploaded or not... oh my!).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 5 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!