AppwriteException: document_already_exists, Document with the requested ID already exists. (409)
- 0
- Databases
- Flutter
- Cloud

Why I got this error I used this code:
final id = ID.unique();
_logger.info('Creating service overview for user $userId');
response = await database.createDocument(
databaseId: serviceCredential.databaseId,
collectionId: serviceCredential.collectionId,
documentId: id,
data: data,
permissions: [
Permission.read(Role.any()),
Permission.write(Role.user(userId)),
Permission.update(Role.user(userId)),
Permission.delete(Role.user(userId)),
],
);
As you can see I used an ID unique but still I got document_already exist in my appwrite cloud . I just have only one document in my collection

Maybe other attributes are unique?

But when I deleting the document it fix the error

If for example the name is unquie And you're trying to insert another one with the same name

You'll get that error

did you mean is the indexes?


I have this

Yes Exactly

Are the value of serverOwnerId
is unqiue each time or same as the one already inserted

So I re create this index


Yes

what should I choose?>

Key or FullText?


Key will suit your use case

thank you I will try

Ohh it works thank youuu so much

Except the cloud, after version 1.3.0 the key is not for allowing queries any more but to enhanced the filtering based on those attributes
Recommended threads
- Unable to create push providers - FCM or...
Currently unable to create a push provider for FCM or APNS.... https://github.com/appwrite/console/issues/2045 When uploading a file... FCM = Valid file retu...
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
- 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...
