Trouble with Updating Document in Appwrite: "Document Data and Permissions Missing" Error
- 0
- Databases
- Functions

Hey Appwrite community 👋,
I’m working on a Python function to decrease user credits, but I keep running into an error when calling the update_document method. Here's the error I’m getting:
[ERROR] Error processing request: Error decreasing user credits: The document data and permissions are missing. You must provide either document data or permissions to be updated.
Here’s a snippet of the code I’m using:
try:
document = self.database.get_document(
database_id=self.db_id,
collection_id=collection_id,
document_id=document_id
)
logger.info(f"User credits: {document['credits']}")
free_credits = document['credits'] - 1
logger.info(f"Decreasing user credits to: {free_credits}")
data = {'credits': free_credits}
self.database.update_document(
database_id=self.db_id,
collection_id=collection_id,
document_id=document_id,
data=data,
permissions=[
Permission.read(Role.user(document_id))
]
)
except Exception as e:
raise Exception(f"Error decreasing user credits: {str(e)}")```
What I’ve Tried:
1. Ensured that data is a dictionary with the credits field.
2. Attempted to pass permissions correctly.
3. Printed and verified the data and permissions before calling update_document
Despite these efforts, the error persists. 🥲
Recommended threads
- Is my approach for deleting registered u...
A few weeks ago, I was advised not to use the registered users' id in my web app. Instead, I store the publicly viewable information such as username and email ...
- ❗[Help] Function stuck in "waiting" stat...
Hi Appwrite team 👋 I'm trying to contribute to Appwrite and followed the official setup instructions from the CONTRIBUTING.md guide to run the platform locall...
- Help with 409 Error on Relationship Setu...
I ran into a 409 document_already_exists issue. with AppWrite so I tried to debug. Here's what I've set up: Collection A has 3 attributes and a two-way 1-to-m...
