If JSON Response is Null, Send it to TRUE Branch

If the JSON Response Contains no Value, Then Send it to TRUE Branch. How to achieve this?

This is the JSON response I’m getting

Selection_197

If TRUE(No data), then Repeat the HTTP Request again

Instead, What is Happening is. Even if the HTTP Response has nothing. It still goes to the FALSE Branch and Sending Message like this. I want to Prevent this.

Selection_198

Here an example workflow which checks if the data (the JSON object) is empty:

2 Likes

I got it Working.

In the Function field of Mock Empty.

I used this code and connected the Branches. It worked.

items[0].json.myVariable = 1;
return items;

Here is my flow.

If the Data is not present. It’ll retry again.

Sorry but do not understand at all. The Function Node was just there to specifically create an empty item. It is not needed in your workflow at all as you said the HTTP Request node does that and you want to test the data it returns.

If you use the code you posted above it would totally defeat the purpose as it simply always sets data. Meaning the data would so never be empty and so there is then no need to even have the IF-Node as it would never execute the empty-path (as it is never empty).

Yes, You’re right, I just tested it. The code I have mentioned isn’t working at all.

This made it work. Thanks @jan

And I’m getting this Error while using Google Sheets Node

ERROR: error:0909006C:PEM routines:get_name:no start line

Error: error:0909006C:PEM routines:get_name:no start line
    at Sign.sign (internal/crypto/sig.js:105:29)
    at Object.sign (/usr/local/lib/node_modules/n8n/node_modules/jwa/index.js:152:45)
    at Object.jwsSign [as sign] (/usr/local/lib/node_modules/n8n/node_modules/jws/lib/sign-stream.js:32:24)
    at Object.module.exports [as sign] (/usr/local/lib/node_modules/n8n/node_modules/jsonwebtoken/sign.js:204:16)
    at Object.getAccessToken (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GenericFunctions.js:65:27)
    at Object.googleApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GenericFunctions.js:29:59)
    at GoogleSheet.getData (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GoogleSheet.js:25:68)
    at GoogleSheet.convertStructuredDataToArray (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GoogleSheet.js:216:42)
    at GoogleSheet.appendSheetData (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GoogleSheet.js:97:33)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GoogleSheets.node.js:556:38)

I followed these things mentioned in this post. But It didn’t help.

If you have that problem you must have missed one of the steps. I advise you to simply start again from the beginning following this guide:

1 Like

This is Great. Will update you soon.

Hey @jan

It worked great, But I’m getting this notification and can’t save the workflow.

And Yes, I’m having the Credential with the same name and not using it for any node.

image

The last two questions/problems in this topic were totally unrelated to the original question. Please make sure to always start a new topic in this case!
If we do not do that, it will become very messy and people that have similar problems will never find the answer to their problem.

Anyway, your problem sounds like this issue:
https://github.com/n8n-io/n8n/issues/949

Sadly was not able to reproduce it. Did you try to select other credentials (you can simply create some temporary ones), save and then select those again and then resave?

1 Like

After a lot of research, testing, back and forth, I solved this problem with an expression for a Boolean comparison:

{{ Object.keys($node.NodeName.json).includes(‘variableName’) }}
Equals
{{ true }}

Hope it helps.

3 Likes

If you’re looking for a no-code solution. Here is how you can do it with IF Block.

I am going to mark this as closed as it is 3 years old. Thanks for the update on it @mcnaveen :raised_hands:

1 Like