Back

Attribute with the requested ID already exists while using ID.unique()

  • 0
  • Self Hosted
  • Web
BloodThermic
3 Dec, 2023, 23:27

I keep getting this error when creating a document. AppwriteException [Error]: Attribute with the requested ID already exists. Try again with a different ID or use "unique()" to generate a unique ID.

This is the line of code that is breaking ``` const data = { Email: Email, accountId: accountId, collectionId: collection.$id, };

let dataLink = await databases.createDocument( "64502243369b884d71f8", "647295a5228d3bd685da", ID.unique(), data );``` Here is the imports

TypeScript
import { PUBLIC_API_ENDPOINT, PUBLIC_PROJECT_ID } from "$env/static/public";
import { PRIVATE_API_KEY } from "$env/static/private";```
TL;DR
The user is encountering an error "Attribute with the requested ID already exists" while trying to create a document. The code they provided includes the use of `ID.unique()`. The solution suggested by the error message is to either use a different ID or utilize the `unique()` function to generate a unique ID.
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