HTTP Actions the best way to validate request body
I am using HTTP Actions and the
request
param is unknown
. There is no documented way to validate request
or how to use built-in validator to validate object shape inside of actions. I am wondering what is the best way to handle this.4 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Please share an example from your code. The HTTP action function should look something like:
yes, given this action when I have
const body = await request.json()
, body is undefined
how could I validate it using convex validator? or do i need to create zod schemas sepoerately and use zod to validate?There's still a lot that you haven't shared about your actual setup, and without that it's tough to know what's happening. Could you please share code snippets of the relevant pieces? E.g. the
httpAction
function definition, the http.route
definition that targets that function, and even an example request to the endpoint.