Back

[SOLVED] Unable to save data Server Error 500

  • 0
  • Web
D5
15 Nov, 2023, 09:24

@Paul Soriano From what I'm seeing there, did you have setup permissions in console, specifically write permission in the collections for this user?

TL;DR
Issue: Unable to save data Server Error 500 Solution: The issue was resolved by correcting the relationship between posts and the users collection. The user adjusted their code to ensure a valid relationship and resolved the error. It was also suggested to check permissions in the console, specifically the write permission in collections for the user.
Paul Soriano
15 Nov, 2023, 09:26

yes,

Paul Soriano
15 Nov, 2023, 09:26

I did setup permission as any

D5
15 Nov, 2023, 09:31

Are you sure all params are valid? Put values like creator, etc in the JSON as a string (between "")

D5
15 Nov, 2023, 09:32

Otherwise the JSON is invalid

Paul Soriano
15 Nov, 2023, 09:33

as I have checked it. all are valid.

Paul Soriano
15 Nov, 2023, 09:33

and I tried only to lessen the passing values, still not working

D5
15 Nov, 2023, 09:33

And did you have tried setting it like this:

TypeScript
{
"title": "Hamlet"
}```
Paul Soriano
15 Nov, 2023, 09:34

const newPost = await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.postCollectionId, ID.unique(), { creator: post.userId, caption: post.caption, // imageUrl: fileUrl.href, // imageId: uploadedFile.$id, location: post.location, tags: tags, } );

Paul Soriano
15 Nov, 2023, 09:34

i have this

Paul Soriano
15 Nov, 2023, 09:34

I just follow the documentation

D5
15 Nov, 2023, 09:35

Try this:

TypeScript
const newPost = await databases.createDocument(
      appwriteConfig.databaseId,
      appwriteConfig.postCollectionId,
      ID.unique(),
      {
        "creator": post.userId,
        "caption": post.caption,
        // "imageUrl": fileUrl.href,
        // "imageId": uploadedFile.$id,
        "location": post.location,
        "tags": tags,
      }
    );
Paul Soriano
15 Nov, 2023, 09:35
Paul Soriano
15 Nov, 2023, 09:36

ok, I will

Paul Soriano
15 Nov, 2023, 09:38

still the same

Paul Soriano
15 Nov, 2023, 09:42

I actually have the same save in user collection and it works fine with this: export async function saveUserToDB(user: { accountId: string; email: string; name: string; imageUrl: URL; username?: string; }) { try { const newUser = await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.userCollectionId, ID.unique(), user );

TypeScript
return newUser;

} catch (error) { console.log(error); } }

D5
15 Nov, 2023, 09:44

Probably the relationship is not valid 🤔

D5
15 Nov, 2023, 09:44

Or you don't have access to the related collection

Paul Soriano
15 Nov, 2023, 09:46

I will review the relation and will get back to you

Paul Soriano
15 Nov, 2023, 09:55

omg it works, you're right. its the relationship issue between posts and my users collection.

Paul Soriano
15 Nov, 2023, 09:58

I can closed this now @D5 . thank you so much for your help. have a nice day.

D5
15 Nov, 2023, 10:23

Great! <:appwritepeepo:1156975874852270110>

D5
15 Nov, 2023, 10:24

Glad to hear it got solved

D5
15 Nov, 2023, 10:24

[SOLVED] Unable to save data Server Error 500

Haimantika
15 Nov, 2023, 12:28

@Paul Soriano can we close this issue? https://github.com/appwrite/appwrite/issues/7141

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