Error Code WDE0027: Cannot Update My Collection

Hello, this is the code I wrote inside the http-functions.js file in the backend. This code works perfectly if I set the update permissions to “public” in my collection settings. However, if I set the permissions to “admin only,” it doesn’t work. What changes do I need to make to the code so that it recognizes me as an authorized user when it runs? I think I need to use the API key I created, but I’m not sure how to implement it. If anyone has knowledge on this topic and can help, I would appreciate it.

export function put_updateKutusu(request) {
    return request.body.json()
        .then((data) => {
            const title = data.title;
            const newKutusu = data.kutusu;

            return wixData.query('Ogeler')
                .eq('title', title)
                .find()
                .then((results) => {
                    if (results.items.length > 0) {
                        let item = results.items[0];
                        item.kutusu = newKutusu;

                        // Kutusu alanını güncelle
                        return wixData.update('Ogeler', item)
                            .then((updatedItem) => {
                                return ok({
                                    body: JSON.stringify(updatedItem),
                                    headers: { 'Content-Type': 'application/json' }
                                });
                            })
                            .catch((error) => {
                                return serverError({
                                    body: "Update failed: " + error.message,
                                    headers: { 'Content-Type': 'application/json' }
                                });
                            });
                    } else {
                        return notFound({
                            body: { error: "Item not found" },
                            headers: { 'Content-Type': 'application/json' }
                        });
                    }
                })
                .catch((error) => {
                    return serverError({
                        body: "Query failed: " + error.message,
                        headers: { 'Content-Type': 'application/json' }
                    });
                });
        })
        .catch((error) => {
            return serverError({
                body: "Invalid JSON: " + error.message,
                headers: { 'Content-Type': 'application/json' }
            });
        });
}

the code identifies which item I want to update in my collection based on the “title” field and then updates the “kutusu” item. I could have used _id for this task, but since the values in the title field are always unique, it doesn’t cause any issues.


When my collection setting is “admin only”


When my collection setting is “public.”

It seems you are attempting to implement a secure endpoint using HTTP Functions.

I would recommend checking out the following article:

As for the CMS permissions issue, HTTP functions are run with the permissions of an anonymous site visitor. To solve this you can use the suppressAuth property on the offending Wix Data methods.