"Undefined" or just no data - what is going on?

Simple work flow triggered by a webhook with json data. Issue is when mapping to data in earlier nodes I get either undefined, or simply no data at all, when there most definitely is data. Not for every field with the sample data provided, but there is data for some of the fields

I have tried adding in .first() and also removing .item() which seems to work on with mautic node on false leg of the IF node, but no such luck on the true leg.

Here is a sample json payload for testing

    "headers": {
      "host": "connect.xxxx.biz",
      "user-agent": "GuzzleHttp/6.5.5 curl/7.68.0 PHP/7.3.24-3+ubuntu20.04.1+deb.sury.org+1",
      "content-length": "1114",
      "content-type": "application/json",
      "x-forwarded-for": "",
      "x-forwarded-host": "connect.xxxxx.biz",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-server": "4d1c1d8abe6b",
      "x-real-ip": "",
      "accept-encoding": "gzip"
    "params": {},
    "query": {},
    "body": {
      "linkedin": "joe-soap-ph-d-14905a2",
      "linkedin_profile_url": "https://www.linkedin.com/in/joe-soap-ph-d-14905a2",
      "name": "Joe Soap Ph.D",
      "first_name": "Joe Soap",
      "last_name": "Ph.D",
      "company": "Nelson Mandela Metropolitan University\nAuthor- Radical Transformation and Sustainability \nMentor \nPhilanthropist \nSports Administrator \nEntrepreneur \nLeadership Innovator\nBusiness Leader",
      "title": "PhD",
      "industry": "Industrial Machinery Manufacturing",
      "education": "Nelson Mandela Metropolitan University",
      "location": "City of Cape Town, Western Cape",
      "connections": "500",
      "experience": [
          "name": "Community Chest of the Western Cape",
          "title": "Chairman of The Board of Directors"
          "name": "Cape Peninsula University of Technology",
          "title": "External Moderator"
          "name": "Fibretek Manufacturing",
          "title": "CEO"
          "name": "Cape Peninsula University of Technology",
          "title": "Chairman Advisory Board"
          "name": "W-Tech Manufacturing",
          "title": "Managing Director"
      "tags": "",
      "campaigns": [
        "Entrepreneurial CEOs in South Africa 2"
      "connected_at": "2023-07-24 20:28:49",
      "webhook_name": "Push connections to member"
  • n8n version: latest
  • Database (default: SQLite): SQ lite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system:

Hi @Robm

I started using .first(0,0) always to make sure the correct runindex etc are used to retrieve the data.
Could you try that?
Also you could merge the data together before going into the if node.

ps. Personally I try to always avoid going back nodes to retrieve data. of course for this use case it makes sense and I would do it as well but if you are talking about multiple items and such things get messed up sometimes. (so not for this use case but wanted to note it anyways)

1 Like

Thanks for taking the time to help. Appreciated.

I tried your fix with no joy. Screen shows that there is data for linked_profile_url but still getting undefined. I have 2 expressions in there to test different options.

I get the feeling we are missing something obvious :thinking:

for me it is working @Robm What version are u running? 1.0.5?

of course I do not have credentials set so it is complaining about that and I also noticed some of the fields arent there but those are correct as well.

this isnt working though
need to do $input.first().body.title here
Also you can easily add the full json payload/ body here to get rid of looking back to the webhook node.
something like this for the return:

  return {
    result: result,
body: $input.first().body

Thanks again @BramKn

I am using the latest version. I updated before posting here to check if an update fixed things.

But bizarrely I just went to look at the workflow again and it’s now working! I changed nothing from the set up in my original post. :person_shrugging:

Something must have been cached somewhere…

1 Like

Amazing, your suggestion of passing the json payload on past the code node worked so well!


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