Back

Message: Collection not found

  • 1
  • REST API
robert_
8 Apr, 2024, 07:17

While writing an internal using the Qt

Error transferring http://uscogdb-v001.i.hmnc.us/v1/databases/hpprx-drug-pricing/collections/6610f0d1003d0ae4b426/documents - server replied: Internal Server Error, {"message":"Server Error","code":500,"type":"general_unknown","version":"1.5.4"}

Following the AppWrite log gives me this,

[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents [Error] Type: Utopia\Database\Exception [Error] Message: Collection not found [Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php [Error] Line: 2623

I'm attempting to perform the following-

TypeScript
/** ...Header snip... **/
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
    , error(new QErrorMessage(this))
{
    connect(ui->cmdSyncData, &QPushButton::clicked, this, [=]() {
        AWDatabasesApi api;
        QEventLoop loop;

        api.setApiKey("drug-import", queryAPIKey());
        api.setNewServerForAllOperations(QUrl("http://uscogdb-v001.i.hmnc.us/v1"));
        
        ui->cmdSyncData->setEnabled(false);
        
        connect(&api, &AWDatabasesApi::databasesListDocumentsSignalE, this, [&](AWDocumentList, QNetworkReply::NetworkError, QString err) {
            ui->cmdSyncData->setEnabled(true);
            qDebug() << "Error.";
            error->showMessage(err);
            loop.quit();
        });

        api.databasesListDocuments("hpprx-drug-pricing", "6610f0d1003d0ae4b426");
        QTimer::singleShot(5000, &loop, &QEventLoop::quit);

        loop.exec();
    });
}

QString Dialog::queryApiKey() {
    return "api-key";       
}
TL;DR
Developer forgot to enable `Document Security` in settings and set permissions for collection. Additionally, set “X-Appwrite-Project” in headers. Server error with message "Collection not found" was due to a missing setting.
xue
8 Apr, 2024, 07:22

did you set “X-Appwrite-Project” in headers?

robert_
8 Apr, 2024, 07:38

hmm

robert_
8 Apr, 2024, 07:40

okay that was stupid- but now I'm getting The current user is not authorized to perform the requested action

xue
8 Apr, 2024, 07:41

you should give permissions

xue
8 Apr, 2024, 07:41

in the settings of collection

robert_
8 Apr, 2024, 07:41

the API key has everything to do with Databases

robert_
8 Apr, 2024, 07:41

oh

robert_
8 Apr, 2024, 07:43

hmm

robert_
8 Apr, 2024, 07:50

Looks like my problem was I forgot to enable Document Security 😄

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more