Unable to save document (form submissions) with REST API

default discord avatar
last year
1 1

I tried payloadcms/plugin-form-builder and I have some questions. How to create form submissions? Should I point my HTML directly to Payload? Richt now, I have proxy function that process data and after that I tried to create new form submission using REST API.

const formSubmission = {
  form: '<some-mongo-id>',
  submissionData: [
    { field: ...', value: '...' },
const res = await apiFetch('<api-url>/form-submissions', {
  body: JSON.stringify(formSubmission),
  method: 'POST',
const formData = new FormData()
formData.append('_payload', JSON.stringify(formSubmission))

const res = await apiFetch('<api-url>/form-submissions', {
  body: formData,
  headers: {
    'Content-Type': 'multipart/form-data',
  method: 'POST',

Neither of these approaches work. They return validation error that prop form is missing, Do you have any ideas what I am doing wrong? I think the documentation lacks details on how to work with REST mutations.


  • discord user avatar
    Payload Team
    last year

    That should work...

    Here is a snippet pulled from a site my team built.

    const dataToSend = Object.entries(data).map(([name, value]) => ({
      field: name,
    const req = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/form-submissions`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      body: JSON.stringify({
        form: formID,
        submissionData: dataToSend
    1 reply
  • default discord avatar
    last year

    Thank you, I think the problem was that I did not specified Content-Type. Dummy mistake!

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.