How to use the IF node when the previous step's output is empty

Describe the problem/error/question

I start my workflow with a form, which will give me an email address. I then check in Gainsight CC if a contact with that email address exists. If there is no contact I want to create a new contact based on the info from the form.

Unfortunately Gainsight CC doesn’t have pre-built node in n8n, so I have to use http, which works.

The strange thing is that it always returns the first user that exists in Gainsight CC, no matter what the input is (= the email I’m looking for). Something doesn’t work correctly, I simple can’t say what, given that data is returned.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Hey @ChristopherG hope all is good.

Based on what I see in the doc

The response should have only a single user which requested given one of the search fields. In your case - “email”.

Hey,
the call goes through without problems, only that the result is wrong. Whatever I put as email address in the request, the result is always the same user in Gainsight CC. It seems that the query parameters name and value are being ignored, hence my question.

What if you send the same request with curl or postman? Is it correct? Does it return more than one result? We want to pinpoint the origin of the problem - if curl/postman returns the same one email - this is either the problem of the remote endpoint returning wrong data or out understanding of what is supposed to be returned by that endpoint.

Toggle off the query parameters and use this url in the same GET method instead:

https://api2-us-west-2.insided.com/user/email/[email protected]

Sometimes the query parameters in the HTTP Request node can cause this kind of problem. That’s why I prefer to use query parameters in the url itself instead.

Note: I feel like the title and the content of your question are unrelated. But to answer the question you asked in the title:

→ Go to node settings and toggle on ‘Always Output Data’ this will allow the node to return empty output.
→ In your IF node set the expression to ‘if empty’ with the correct type (e.g. string)

In Postman, the command /user/email/[email protected] went through successfully.
I then disabled the “Send Query Parameters” and modified the URL directly. It looks better, but now I get this %20 in the URL. Where does it come from? I simply dragged the field “email address” from the form into the URL.

%20 is a space, you need to trim your value

{{ $json['Your email address(private email address preferred)'].trim() }}

1 Like

Actually, the space was in front of the {{ and not inside. I only saw it when I opened the URL in the big editor window.
Problem solved

1 Like

You are correct, there is a mismatch :innocent: , must have been a mix-up with another post I was drafting.

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