Back

status 500

  • 0
  • Storage
stella
21 Dec, 2023, 00:46

the server respond with status 500. i am trying to post cant go through at appwrite cloud

TL;DR
The user is experiencing a status 500 error when trying to post using Appwrite cloud. They are unsure of how to get the payload and which part of the code to share. They provide code snippets for the post form and ask for help in resolving the error. No solution is provided in the thread.
Drake
21 Dec, 2023, 01:55

please provide more detail

stella
21 Dec, 2023, 02:00

you can please have a look at the screenshot

Drake
21 Dec, 2023, 02:02

please share your code, request payload, and project id

stella
21 Dec, 2023, 02:05

VITE_APPWRITE_PROJECT_ID='6581d9959beb7f0151cb'

stella
21 Dec, 2023, 02:05

which part of the cord should i share

stella
21 Dec, 2023, 02:06

i also dnt know how to get the payload. i am in the learning process

stella
21 Dec, 2023, 02:06

import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import * as z from "zod" import { useNavigate } from "react-router-dom";

import { Button } from "@/components/ui/button" import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form" import { Input } from "@/components/ui/input" import { Textarea } from "../ui/textarea" import FileUploader from "../shared/FileUploader" import { PostValidation } from "@/lib/validation" import { Models } from "appwrite" import { useUserContext } from "@/context/AuthContext" import { useToast } from "../ui/use-toast" import { useCreatePost } from "@/lib/react-query/queriesAndMutations";

type PostFormProps = { post?: Models.Document; }

const PostForm = ({ post }: PostFormProps) => { const { mutateAsync: createPost, isPending: isLoadingCreate } = useCreatePost(); const { user } = useUserContext(); const { toast } = useToast(); const navigate = useNavigate();

TypeScript
// 1. Define your form schema.

const form = useForm<z.infer<typeof PostValidation>>({ resolver: zodResolver(PostValidation), defaultValues: { caption: post ? post?.caption : "", file: [], location: post ? post?.location : "", tags: post ? post.tags.join(',') : "" }, })

// 2. Define a submit handler. async function onSubmit(values: z.infer<typeof PostValidation>) { const newPost = await createPost({ ...values, userId: user.id, }) if(!newPost) { toast({ title: 'Please try again' }) } navigate('/');

stella
21 Dec, 2023, 02:07

that the post form

Drake
21 Dec, 2023, 02:09

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

Drake
21 Dec, 2023, 02:10

your browser dev tools has network logs. you can look through that for your request

Drake
21 Dec, 2023, 02:12

file is not a valid attribute in your collection

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