How to sort data into http request automatically

Hey Guys

I have got data like

I only want to place the data if the there is a value in the string like person location does not have a value so I dont want that in http request. so how can I make it work
Do I have to write if node for every single value or there is some other way to do this

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:

@Arsh_Tyagi , depending on what you do with this data later on in the workflow, you can use either IF node or Filter node. The condition would be to check if person location “is empty”.

I will have to place this all data into http request and using the API key I will make request.

I only want the data that contains a value not the data that is empty. Can we have a code for this.

I tried using the if node It gave me the whole data as discarded. so could you give me an code to get only the data which contains any value

@Arsh_Tyagi , I think I misunderstood your requirement. So, you want to remove those properties from an object that have no value (that is have null as a value)? If that is so, here’s your code assuming there is only one item (hence, I used $input.first().json),

const output = {};
for (i of Object.entries($input.first().json)) i[1] ? output[i[0]] = i[1] : null;

return output;

Working example follows.

it is still giving me objects with no result

@ihortom Instead of code I have used this

I have 2 problems in this one the data is coming in this format [{“organization_ids”:null},{“organization_num_employees_ranges”:“["21,50","51,100"]”},{“organization_industry_tag_ids”:“["5567ce1f7369643b78570000"]”},{“contact_email_status_v2”:“["likely_to_engage","verified"]”},{“person_titles”:null},{“q_organization_keyword_tags”:null},{“included_anded_organization_keyword_fields”:null},{“q_not_organization_keyword_tags”:null}

but I want it to look like , “organization_industry_tag_ids”:[“5567ce1f7369643b78570000”],“contact_email_status_v2”:[“likely_to_engage”,“verified”] without any {{ // or extra “”

How can I achieve this using { "meta": { "templateCredsSetupCompleted": true, "instanceId": "bb46f6407a7cc1da0bd50cfcb16594259e2c4e949debacf0dcf2dbfd5ce0e106" }, "nodes": [ { "parameters": { "jsCode": "const allData = []\n\nlet counter = 0;\ndo {\n try {\n const items = $items(\"No Operation, do nothing1\", 0, counter).map(item => item.json);\n allData.push.apply(allData, items);\n } catch (error) {\n return [{json: {allData}}]; \n }\n\n counter++;\n} while(true);" }, "id": "54fa8f13-ae22-4712-81ab-369bc1d80d2b", "name": "Code", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1940, 1920 ] } ], "connections": {}, "pinData": { "Code": [ { "allData": [ { "organization_ids": null } ] } ] } }

also there is one more problem if I am using call for another workflow node in the end the workflow runs incomepletely . If i remove the execute another workflow node then the workflow runs all the nodes

Here is the workflow I want to place this all information in http request for making API request and if I place object with no value then http gives an error so this is important for that

@Arsh_Tyagi , you are not using my code in the right place. The single node I provided replaces all of your IF nodes. It becomes just this up to Spreadsheet node.

Mind you the Set3 node had no data pined to test (at least it is empty for me) but I’m confident that it should work (unless I still do not follow your initial requirement). All your set nodes should be in a single Set (“Flatten data”) combining all the properties (I left that part for you to complete).

We can come to the reset of your questions later as those seem to be a different topic from your original question.

1 Like

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