Not able to uplaod mp3 file to soundcloud



  • Is their anyone who worked on QT Soundcloud Integration

    I am trying to upload mp3 files to soundcloud using Qt but not able to upload

    After verifying and getting acces_token

    I am using post to upload mp3 file

    @
    QString uplaodurl = "https://api.soundcloud.com/tracks.json";

    QString file = "C:/Users/Admin/Music/songs/audio.mp3";
    QFile Opfile(file);
    if(Opfile.open(QIODevice::ReadOnly)){

    QEventLoop q;
    QTimer t1;
    t1.setSingleShot(true);

     connect(&t, SIGNAL(timeout()), &q, SLOT(quit()));
    

    QByteArray oauthHeader1 = generateAuthorizationHeaderForSoundClound(url, OAuth::POST);
    QString ohead(oauthHeader1);

    QNetworkRequest req1(uplaodurl);

    req1.setRawHeader(AUTH_HEADER, oauthHeader1);

    QString str = "track[recording]";
    QString str1 = "track title";
    QString assetdata = "track[asset_data]";
    QString str2 = "oauth_token";
    QString path = "C:/Users/Admin/Music/songs/audio";

    //req1.setRawHeader(str1.toUtf8(), str.toUtf8());
    //req1.setRawHeader(assetdata.toUtf8(), path.toUtf8());

    QByteArray arr = Opfile.readAll();
    QString updata(arr);

    QNetworkReply *reply = m_netManager->post(req1, &Opfile);
    connect(reply, SIGNAL(finished()), &q, SLOT(quit()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error()));

    t1.start(150000);
    q.exec();

    if(t1.isActive()){
    QByteArray response = reply->readAll();
    parseTokens(response);
    reply->deleteLater();

    mHaspin = !m_oauthToken.isEmpty() && !m_oauthTokenSecret.isEmpty();
    

    }
    @

    Response:

    {"errors":[{"error_message":"401 - Unauthorized"}]}

    But if i make get call then respose is positive --

    [edit: added missing coding tags @ SGaist]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.