How can I programmatically generate nodes in a flow?

  1. export a simple flow - a selection of nodes (i used an Inject and a Debug node)
  2. copy its json - because obviously i wasnt gonna sit and type all that in :wink:
  3. based on the docs constracted the body of the request and pasted in nodes property the json from step 2
  4. deleted my test flow with the Editor so there wont be a clash of ids / names etc
  5. tested the POST with POSTMAN software
  6. translated the request with it to Curl, for you to have fun
curl --location --request POST 'http://192.168.0.7:1880/flow/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id": "91ad451.f6e52b8",
    "label": "Sheet 1",
    "nodes": [
        {
            "id": "59bf67591ceff3bd",
            "type": "inject",
            "z": "5ae48088f8ce401d",
            "name": "",
            "props": [
                {
                    "p": "payload"
                },
                {
                    "p": "topic",
                    "vt": "str"
                }
            ],
            "repeat": "5",
            "crontab": "",
            "once": false,
            "onceDelay": 0.1,
            "topic": "",
            "payloadType": "date",
            "x": 290,
            "y": 140,
            "wires": [
                [
                    "7b4c39e88a441a69"
                ]
            ]
        },
        {
            "id": "7b4c39e88a441a69",
            "type": "debug",
            "z": "5ae48088f8ce401d",
            "name": "",
            "active": true,
            "tosidebar": true,
            "console": false,
            "tostatus": false,
            "complete": "false",
            "statusVal": "",
            "statusType": "auto",
            "x": 490,
            "y": 140,
            "wires": []
        }
    ],
    "configs": []
}'
1 Like