Join the Webstudio community

Updated 2 months ago

Json form

At a glance

The community member is trying to submit a webhook form with a JSON payload, but the form is currently submitting with a text/plain;charset=UTF-8 content type, which is not compatible with the Directus API that requires JSON. Other community members respond that HTML forms generally do not support JSON content types, but they are working on a solution to enable this functionality. They mention creating an issue on the Directus repository and on their own project's repository to track this feature request. The community members discuss the importance of being able to send and receive JSON data through forms, as it will greatly expand the capabilities of forms. They also mention that this feature is a side priority compared to their current focus on CSS variables, but they are considering prioritizing it depending on the complexity involved.

Useful resources
It looks like the webhook form submits with content-type text/plain;charset=UTF-8. Is there a way to have it submit with content-type application/json? I'm playing with using Directus to receive form submissions, and it requires a JSON payload
O
p
14 comments
Html forms in general don't support json content type, but we are cooking something to enable this and setting headers etc. basically using resource in forms
Awesome, thanks for getting back to me. When there's an issue for it, could you share a link?
There's a request on Directus for accepting other request bodies, but it's only a few days old https://github.com/directus/directus/issues/23143
yeah, it should be a good practice for any api endpoint to accept form encoding as well, but there is no consistency, so we really need to be able to send json too
awesome, thanks for planning this and setting up an issue!
With this done, Forms will become basically allmighty, especially once you can also bind response to any rendering
so not only sending, but also using the responses
I was wondering about exactly this! Fantastic. Is this going to be a next few weeks thing, or a later this year thing, do you think?
I am considering to prioritize it but it depends on @TrySound estimate of complexity
Our main priority right now is css variables, so its another side quest, but its so powerful, we need to do it
https://github.com/webstudio-is/webstudio/issues/3872 also follow this one, with this you can not only pass json data to the client-side scripts, but also once the forms fetch json, pass that json to client-side js and do anything with it that is completely custom
oh, this is great too. will really open up possibilities
Thank you for all the info, and also I'm very much looking fwd to css variables
Add a reply
Sign up and join the conversation on Discord