Passing data between WFs, why can't my example work?

calling-WF : webhook (post-data) + execute-WF
called-WF : http-request

This woks, but i can’t get the post-data in the http-request, how can i do ?

calling-WF

{
  "name": "calling-WF",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "workflowId": "10"
      },
      "name": "Execute Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        760,
        300
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "b55b1dbe-e791-4f13-b291-5dd869d26494",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        520,
        300
      ],
      "webhookId": "b55b1dbe-e791-4f13-b291-5dd869d26494"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "id": "11"
}

called-WF

{
  "name": "called-WF",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/ea9c33e3-8dcb-4ca5-b30a-afbf093db57a",
        "allowUnauthorizedCerts": true,
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        480,
        300
      ]
    }
  ],
  "connections": {},
  "active": false,
  "settings": {},
  "id": "10"
}

It looks like in the called-WF you did not connect the Start-Node with the HTTP Request one.

Excuse me jan i did too, but same result, even if i set “always output data” in the start node
At execution, I see my post data in the start node but the http-request node remains empty

 "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },

What do you mean with it remains empty? Do you mean in the Editor-UI? If so you will never see any sub-workflow execution there, they always run in the background.

Here are the 2 nodes in the execution dashboard, no data for the second
For example, how to pass “counter” in post data of http-request ?
pic pic1

It looks like the call does not return any data. You can see that it says “Results: 1” so the call got made but apparently the response is simply empty.

Argh misunderstanding … yes, the http-request output is empty
But the i would like to pass “counter” into post-data of this node, as i can see that post data is empty in webhook.site … how can i do ?

You would have to pass then the counter-data into the Execute Workflow-Node. You can find information about how to get data in and out of sub-workflows here:
https://docs.n8n.io/nodes/n8n-nodes-base.executeWorkflow/#how-does-data-get-passed-from-one-workflow-to-another

:yum: already read jan … very concise, too maybe
yes the Start node receives the data from the calling-WF, but do I need a Function node to feed the Http-request node input ? i would have prefer to start this called-WF with this node but the Start node seems mandatory here

Not sure if I understand you correctly but I do my best.

The called workflow always starts from the Start-Node. As each workflow has one that is the best entry point.
Not sure what you mean with the Function-Node. Is it to provide kind of default data for development? If so then yes you could use a Function or Set-Node for that.

Argh jan sorry to not be clear enough
Let’s do short : how would you pass the “counter” property and its value (coming form the calling-WF) into the post-data (of the Http-request in the called-WF) sent to webhook.site ?
Since i can’t use any Start-node’s output in expressions (in Set for ex)
Can i be clearer ? :blush:

Yes you can still use it in an expression, you can just not select it manually via the Expression-Editor. So if you write:

{{$node["Start"].json["counter"]}}

You will not see a result, as there is currently no data, but if the workflow then executes it will resolve correctly.

What you could also do is something like this (workflow at the end):

For development, you set the init-date (example-data) on the “Set Init-Data” node. If you have to set expressions you reference them always from the “Input Data” node. Once you then want to run the workflow in production you disable the “Set Init-Data” node and it will still work perfectly.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "number": [
            {
              "name": "counter",
              "value": 1
            }
          ]
        },
        "options": {}
      },
      "name": "Set Init-Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {},
      "name": "Input Data",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/ea9c33e3-8dcb-4ca5-b30a-afbf093db57a",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "counter",
              "value": "={{$node[\"Input Data\"].json[\"counter\"]}}"
            }
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set Init-Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Init-Data": {
      "main": [
        [
          {
            "node": "Input Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Data": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks jan, sorry but my primary case can’t work yet, no post data in webhook.site when i use
{{$node[“Start”].json[“counter”]}} in body parameter name

{
  "name": "called-WF",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://webhook.site/ea9c33e3-8dcb-4ca5-b30a-afbf093db57a",
        "allowUnauthorizedCerts": true,
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "={{$node[\"Start\"].json[\"counter\"]}}"
            }
          ]
        },
        "queryParametersUi": {
          "parameter": [
            {}
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        480,
        300
      ],
      "alwaysOutputData": true
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "10"
}

Because the counter data is not on the top level, it is underneath “body”. So the expression would have to be adjusted to account for that:

{{$node["Start"].json["body"]["counter"]}

Yes i saw that, and fixed it, but result is not ok yet :
In the execution journal, we find the value :
image
and in webhook.site :
image

Result looks correct, at least it does exactly what you told it to do. You set the “Name” to 467 and the “Value” empty. I guess what you want is to set “Name” to a static value (like “counter”) and “Value” to the expression.

You guess well jan :slight_smile: how ?

I must be a genius :wink:

In every joke there is always an element of truth … :wink:

Ok jan, I see the principle, and I didnt’ know than I could use the ‘Start’ in expression to use its $json (miss in doc!)

Thanks a lot !

Glad to hear that it works now at least.

What exactly do you mean is missing? The documentation for $node can be found here:
https://docs.n8n.io/nodes/expressions.html#variable-node