I am trying to create a document in appwrite `
const read = await this.databases.createDocument(config.databaseID, config.userReadCollectionID, JSON.stringify(data),ID.unique());
But i am getting this error.
AppwriteException: Invalid
documentIdparam: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char
I tried slicing the uniqueId to below 36 but it still doesn't works
The third parameter to createDocument()
is the documentId:
async createDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document>
So, it looks like you're passing JSON.stringify(data)
for the documentId which is probably invalid. It should probably be:
const read = await this.databases.createDocument(config.databaseID, config.userReadCollectionID, ID.unique(), data);
assuming data
is a JSON object.