Data Move on from Node1 to Node3 based on Empty HTTP Output on Node2

As described in the title, I currently have 3 nodes:

Node1: Contains all the data I need for further actions.

Node2: Will make a HTTP request for searching based on the ID I got from Node1. If the output is empty, which is what I want, meaning that this ticket has not been created before.

Node3: If output from Node3 is empty, make another HTTP request to create the ticket.

Problem(s) that I’m facing:
Even with “Always Output Data” turned on, Node2 will only pass on HTTP responses that has content. All empty responses will just be gone. I can’t refer to these empty response on Node2 to grab data from Node1 and make new request.

Hi @BeStill, I understand you’d like to access data from your Node1 in Node3, even if your Node2 does not return any useful result. Unfortunately, the HTTP request node will replace the incoming data with whatever response it receives in such a scenario (even if that response is empty). This has caught people off guard a few times now, and I’m hoping that in the future we’ll optionally allow incoming data to be retained.

For the time being you’d want to use a Merge node to bring back the incoming data after your Node2. You didn’t confirm which version of n8n you are using, but assuming this is the latest available a workflow like below would do the job:

This will need some fine-tuning depending on what your data from Node1 and Node2 looks like, but I hope it shows the basic idea :slight_smile:

1 Like

@MutedJam Appreciate it. I’m trying the approach you suggested. Being able to retain data from previous notes would be great for future versions.

By the way, I’m wondering if “Merge – Append” would be able to output either input when the other input is empty? Because I have data that are split out “Switch” for value modification. However, not all of them will have data available for modification. After that, I would like to combine them back together as a whole.

1 Like

Hi @BeStill, this should work for the most part, but there are two caveats:

  1. You’d need to upgrade to n8n version 1 for this to work. That’s because for previous versions of n8n the Merge node would try to pull in data even from branches that wouldn’t otherwise run which can lead to unexpected behavior. This change is documented here in the migration guide: n8n v1.0 migration guide | n8n Docs
  2. You’d need to use multiple Merge nodes and connect each of your Switch branches to its own input on the respective Merge node.

You’ll then be able to use a pattern like this:

This would return a single list of items after the last Merge node:

Hope this helps :slight_smile:

Thanks @MutedJam . For “Merge”, do you mean both input1 and input2 are required to have some data in order to execute it? Unless I upgrade to v1.0. Correct me if I’m getting this wrong.

For “Merge”, do you mean both input1 and input2 are required to have some data in order to execute it? Unless I upgrade to v1.0.

Yep, exactly. Before version 1 the merge node would try to pull in data from each input.

Starting with version 1 that’s no longer the case (and you can configure the behaviour).

Gotcha. Thanks @MutedJam

1 Like

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