Back

`Invalid document structure: Missing required attribute "expire"` on `users.createSession()`

  • 0
  • Self Hosted
  • Auth
ideclon
12 Apr, 2024, 02:27

I'm trying to call $users->createSession($userId). I receive a 500 Server Error, and in the Appwrite logs, I see [Error] Message: Invalid document structure: Missing required attribute "expire".

Appwrite v1.5.4 PHP SDK 11.0.1

TL;DR
Issue: Developer getting a 500 Server Error with message "Invalid document structure: Missing required attribute 'expire'" while calling `$users->createSession($userId)` in Appwrite v1.5.4 using PHP SDK 11.0.1. The error seems to be related to the difference in how `expire` attribute is handled in different methods. Solution: Edit the `createSession()` method in the `users.php` controller to ensure that `expire` attribute is correctly included in the `Document` creation step before calling the method.
ideclon
12 Apr, 2024, 02:45

My guess as to why this is happening - I see in POST /v1/account/sessions/token ($account->createSession()), expire is in the new Document() declaration (https://github.com/appwrite/appwrite/blob/505637d1190881d131fbe2eb003e6b27676a4387/app/controllers/api/account.php#L106), whereas in POST /v1/users/:userId/sessions ($users->createSession(), expire is added after the Document is created (https://github.com/appwrite/appwrite/blob/505637d1190881d131fbe2eb003e6b27676a4387/app/controllers/api/users.php#L1811).

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