Empty Webhook Response (even though its hard coded)

I am building a workflow where midway through I filter an array and set an if node that if the output from the filter is not empty, then the false branch has a Respond with a Webhook response of 400 with this json hard coded.
{
“matched”: false,
“message”: “No match found”
}

When I run it through the scenario with the correct parameters and missing data (so the filter will return empty), the data correctly flows through the If node to the webhook response and the output is empty. Even though the response is hard coded, it comes out as:
[
{
}
]

Why would it be doing this?

Heres a quick Loom

Thanks!

  • **n8n version:1.18.0
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (own):
  • Running n8n via (Docker):
  • **Operating system:Mac

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@harrison, the workflow appears to me to work as per design. You are checking for an empty item in the list and you seem to have found one. As the item itself is empty ($json.isEmpty()) then there is essentially no data to pass to the next node and hence the next node (“webhook response”) does not run.

If I understood the requirements right you want to reply to webhook request when an item without a zip code is found. In that case, you might want to get rid of an empty item(s) in the list first and then search for an item that has no zip code, which should be passed over to “webhook responce” node. Also make the response node runs only once in case you have more than one item without a zip code.

Thanks for the response. The data that is coming in is querying a database and checking if that zip code is contained in the database and the workflow is performing correctly. We want to send a response to our workflow no matter the outcome.

What I do not understand how the webhook response node works.
I hard code the response body to be
{
“matched”: false,
“message”: “No match found”
}

and it ignores my harded coded body and passes through the json from the step before (which is empty)

My questions are:

  1. Why is it ignoring my hard coded response body?
  2. How do I choose what goes into the response body if not in the in the response body field?

Hey @harrison,
thank you for the really detailed description.

The answer for is is actually pretty simple and short. You defined to respond immediately in the Webhook node. So it is not waiting for the respond to webhook node.

You need to change it to Using Respond to Webhook Node

Cheers.

I love simple and short fixes! Thanks @nico-kow!

1 Like

Now testing it, I picked Respond to Webhook Node in the dropdown but the response is still empty :sleepy:

Any where else I could be going wrong?

@harrison ,

Why is it ignoring my hard coded response body?

As I mentioned earlier, for the node to run it has to have a non-empty item passed over to it. With “IF” node, you are testing if item is empty and if it is it goes to “Webhook Response” node. As a result, that node does not “fire” as it received an empty item.

Having said that, when “Webhook Response” node does get activated it outputs what it received, not what you provided in the JSON body manually (by design).

Here’s an example how Webhooks work. The “Set” node explicitly outputs some data and as a result “Webhook Response” node gets engaged and outputs what it received while returning the application that triggered the “Webhook” node the body specified in “Webhook Response” node (you could see it when testing it in the browser when using the webhook URL in the browser, which could be seen when running in production mode, not test).

Now, if an empty item comes in to “Webhook Response” node it does not fire as demonstrated in the next workflow. I used Code node and output an empty item.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.