Receiving a form submission

I was trying to use webhook as receiver of a html form. Testing it

curl -X POST -F '[email protected]' -F 'name=john' https://n8n.foo.com/webhook-test/1/form1/subscribe

unfortunately the content is not available

[
  {
   "body": {
    },
    "headers": {
      "host": "...",
      "x-forwarded-for": "...",
      "connection": "close",
      "content-length": "248",
      "user-agent": "curl/7.64.1",
      "accept": "*/*",
      "content-type": "multipart/form-data; boundary=------------------------a5ee002ec1f2b7e1"
    },
    "query": {
    }
  }
]

What works is

curl -X POST -H 'Content-Type: application/json' -d '{"email":"[email protected]","name":"john"}' https://n8n.foo.com/webhook-test/1/form1/subscribe

as it returns the data in the body

[
  {
    "body": {
      "email": "[email protected]",
      "name": "john"
    },
    "headers": {
      "host": "...",
      "x-forwarded-for": "...",
      "connection": "close",
      "content-length": "41",
      "user-agent": "curl/7.64.1",
      "accept": "*/*",
      "content-type": "application/json"
    },
    "query": {
    }
  }
]

Unfortunately that is not so useful for straight up html forms.

The next problem is that on a form submission the response should probably more than just

200 {"message":"Workflow got started."}

Now the question is: Should the webhook node be improved or should this be a different node altogether? Or is there another way that I missed?

Thoughts?

Yes, that is sadly currently not possible. But I do not think that a separate node would be needed for it. It should either be possible to check what kind of data got received and then send it into the workflow accordingly or if it would interfere for some reason with existing behavior a simple option can be added which is deactivated by default.

About the response data. If you set the “Response Mode” on the Webhook-Node to “Last Node” you should be able to return whatever data you want.

Hope that helps!

1 Like

Sounds good. I guess the content type should allow for handling this automatically.
So I guess we should add this. Maybe the “webhook” is rather a “http in” then?

About the response data: When using “Last Mode” it means there is no way to have the content depend on the request though - is there?

Yes, that would probably also be a valid name. But at that point in time changes like that are sadly not possible anymore. However, in a later version such and many other things can hopefully be improved.

Using the data of the request is no problem with the mode “Last Node”. You can literally return anything you want. It is possible to reference in any node the data of any of the previous ones. So no matter if you have two nodes in the workflow or 10k you will always be able to reference or pipe-in the data of the Webhook-Node.

1 Like

Is there any progress on receiving a form? I just ran into this again.

We actually needed something like that a few weeks ago for an integration. Building that into the Webhook-Node should not be too complicated. I will try to look into it in the next days.

1 Like

@tcurdt just finished this. Jan will let you know when is released.

2 Likes

Wow - awesome. Thanks for that!

1 Like

Got released with [email protected]

1 Like