Back

Invalid `documentId` param: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and un

  • 0
  • Databases
  • Flutter
  • Self Hosted
kirusha
23 Dec, 2023, 18:27

in Flutter App i have a class, let's call it the car class.

i create a new Car:

Car( id: ID.unique(), created: true, )

and on other place there is a function which is called: if car.created == true:

...databases.createDocument( databaseId: ENV.APPWRITE_DB, collectionId: ENV.CAR_COLLECTION, documentId: car.id, data: car.toAppwrite(), );


my problem is: i get this error in return:

AppwriteException: general_argument_invalid, Invalid documentId param: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore (400)<…>

would be great for any solutions and explanations of the reason.

TL;DR
The user is experiencing an error with an invalid `documentId` parameter. The `documentId` must be at most 36 characters and can only contain letters (a-z, A-Z), numbers (0-9), and underscores. It cannot start with a leading underscore. The error occurred when trying to update a document using the `updateDocument` endpoint with a PATCH method. The status code returned was 400. The user is asking for a solution and an explanation of the reason.
Christy Jacob
23 Dec, 2023, 19:04

What does your car ID look like ?

Christy Jacob
23 Dec, 2023, 19:05

Would help if you print the value of car.id before you make the call to createDocument()

kirusha
23 Dec, 2023, 19:27

i get: "unique()" in return

Christy Jacob
23 Dec, 2023, 19:27

are you able to open your app on the browser and inspect the network request?

kirusha
23 Dec, 2023, 19:29

hm, i can try to check it with the dev tools

Christy Jacob
23 Dec, 2023, 19:29

yea that would be helpful 👍

kirusha
23 Dec, 2023, 19:37

request uri: https://appwrite.domain.com/v1/databases/alpha_db/collections/car/documents/unique() method: PATCH status: 400

request: {"data":{"title":"test2"}}

response: {"message":"Invalid documentId param: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore","code":400,"type":"general_argument_invalid","version":"1.4.13"}

Christy Jacob
23 Dec, 2023, 19:39

You;re hitting the updateDocument endpoint as indicated by the PATCH method

Christy Jacob
23 Dec, 2023, 19:39

so you're trying to update a document with id unique() which does not exist

kirusha
23 Dec, 2023, 19:40

lol you right

Christy Jacob
23 Dec, 2023, 19:41

Hope that solves the problem ?

kirusha
23 Dec, 2023, 19:41

yes, thank you very much

Christy Jacob
23 Dec, 2023, 19:41

No worries 👌

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