
I am stuck with authentication using appwrite. I am getting bad request 400 error when trying to register though we already have project, database, collection created on Appwrite and those are correctly configured in our application code as well.

Can you post the relevant code, and the exact error being thrown?

This is the code for creating account in auth.js file
async createAccount({email, password, name, address, city, role}) { try { const userAccount = await this.account.create(ID.unique(), email, password); if(userAccount) { //call another method
await this.database.createDocument(
conf.appWriteDatabaseId,
conf.appWriteCollectionId,
ID.unique(),
{
userId: userAccount.$id, // Link this document to the created user
name,
address,
city,
role
}
);
console.log("User document created:", document); // Log created document
return this.login({email, password});
}
else {
return userAccount;
}
} catch (error) {
console.error("Error creating account:", error);
throw error;
}
}
The error I am getting in console is:
POST https://cloud.appwrite.io/v1/databases/671fbea…/collections/671fc12…/documents 400 (Bad Request)
createAccount @ auth.js:23
await in createAccount
handleSubmit @ Register.js:154
Show 23 more frames

So it looks like it's throwing an error when trying to create a new document. Are permissions setup correctly on that collection?

Yes, my collection has all 4 CRUD operations access for all users
Recommended threads
- File tokens regenerate each page reload
Hello, on appwrite 1.7.4, when I create a file token via the API Tokens(appwriteAdminClient)#createFileToken I get a secret, then when I check in the console t...
- CSV Import Shows Success but Data Not Ap...
I tried importing a CSV file into my PRODUCTS collection. The dashboard shows the message “Import to PRODUCTS completed successfully,” but no data appears in th...
- Console create row ui not passing ID.uni...
I'm getting an error saying the id is already used but it should be created with ID.unique() it doesn't seem to be reading the row ID field at all. I can't get ...
