Database location

Good morning,
As part of the industrialization of my processes, I would like to automate the creation of flows in node red.

To be more precise, I want to have an SD card with a basic stream that would allow me to make a copy from a specific file containing a JSON node red.

Can I do an import flow directly through a node? if not can I tell node red to make a copy and paste in the nodered source folder where the flows are located. and then a restart? if so where is the folder containing the flows located?

You can use the admin api to post a flow Admin API Methods : Node-RED

Great! but flows.write authorization is required. How can I activate this? I can't find the information on the site.

I don't have identification on my node-red

I tried another approach via postman.

now i have an error

{
"code": "unexpected_error",
"message": "config.forEach is not a function"
}

with body :

{
"id": "91ad451.f6e52b8",
"label": "test",
"nodes": [{"id":"b26325bc.6122d8","type":"tab","label":"Sywa","disabled":false,"info":""},{"id":"81f4e74d.24eee8","type":"http request","z":"b26325bc.6122d8","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":470,"y":220,"wires":[["5076216b.6ecc8"]]},{"id":"ef9709bf.b95f18","type":"change","z":"b26325bc.6122d8","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"client_id=web_app&username=accesscontrol@sywa.fr&password=Accesscontrol1!&grant_type=password","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"https://auth.app.sywa.fr/auth/realms/sywa-preprod/protocol/openid-connect/token","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":220,"wires":[["81f4e74d.24eee8"]]},{"id":"79c194a9.a950ec","type":"inject","z":"b26325bc.6122d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":220,"wires":[["ef9709bf.b95f18","8094763.a62db88"]]},{"id":"5076216b.6ecc8","type":"change","z":"b26325bc.6122d8","name":"","rules":[{"t":"set","p":"token","pt":"global","to":"payload.access_token","tot":"msg"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"global"},{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.Authorization","pt":"msg","to":"\"Bearer " & $$.token","tot":"jsonata"},{"t":"set","p":"headers.Accept","pt":"msg","to":"application/json","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"https://api.preprod.sywa.fr/access-controls/2/attendees","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["bc23a03b.fa0a8"]]},{"id":"bc23a03b.fa0a8","type":"http request","z":"b26325bc.6122d8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":810,"y":220,"wires":[["6a0d7785.a576a8"]]},{"id":"6a0d7785.a576a8","type":"split","z":"b26325bc.6122d8","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":950,"y":220,"wires":[["7e7bf58f.ecfd1c","ba414ab7.ea59e8"]]},{"id":"ee3ecafb.5dddf8","type":"debug","z":"b26325bc.6122d8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":280,"wires":},{"id":"8094763.a62db88","type":"function","z":"b26325bc.6122d8","name":"DELETE ","func":"var newMsg = {\n"topic" : "DELETE FROM access_valid WHERE 1"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":280,"y":280,"wires":[["7f94c7eb.f4d0c8"]]},{"id":"3f5e09ad.eada76","type":"Stackhero-MySQL","z":"b26325bc.6122d8","server":"6e6c4c1b.6c0d54","name":"","x":1250,"y":220,"wires":[]},{"id":"7f94c7eb.f4d0c8","type":"Stackhero-MySQL","z":"b26325bc.6122d8","server":"6e6c4c1b.6c0d54","name":"","x":430,"y":280,"wires":[["ee3ecafb.5dddf8"]]},{"id":"7e7bf58f.ecfd1c","type":"change","z":"b26325bc.6122d8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":""INSERT INTO access_valid(Id,lastName, firstName, projectStatus, projectName, projectdateEnd, projectdateStart, employerName) VALUES ('"&payload.id&"','"&payload.lastName&"','"&payload.firstName&"','"&payload.project.status&"','"&payload.project.name&"','"&payload.project.dateEnd&"','"&payload.project.dateStart&"','"&payload.employer.name&"')"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":220,"wires":[["3f5e09ad.eada76"]]},{"id":"ba414ab7.ea59e8","type":"debug","z":"b26325bc.6122d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":120,"wires":},{"id":"6e6c4c1b.6c0d54","type":"Stackhero-MySQL-Server","name":"","host":"localhost","port":"3306","tls":false,"database":"accesssite"}]
}

Thanks for your help

I have this error but i don't have the solution .

{
    "code": "unexpected_error",
    "message": "invalid node type: tab"
}

The flow you posted is corrupt, use the </> button when posting code.

Also show us what you have tried.

Are you trying to post that to the admin api, via postman, or what?

{
  "id": "8",
  "label": "test",
  "nodes": [{"id":"84e74d.24eee8","type":"http request","z":"b26325bc.6122d8","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":470,"y":220,"wires":[["5076216b.6ecc8"]]},{"id":"ef9709bf.b95f18","type":"change","z":"b26325bc.6122d8","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/x-www-form-urlencoded","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"client_id=web_app&username=accesscontrol@sywa.fr&password=Accesscontrol1!&grant_type=password","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"https://auth.app.sywa.fr/auth/realms/sywa-preprod/protocol/openid-connect/token","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":220,"wires":[["81f4e74d.24eee8"]]},{"id":"79c194a9.a950ec","type":"inject","z":"b26325bc.6122d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":220,"wires":[["ef9709bf.b95f18","8094763.a62db88"]]},{"id":"5076216b.6ecc8","type":"change","z":"b26325bc.6122d8","name":"","rules":[{"t":"set","p":"token","pt":"global","to":"payload.access_token","tot":"msg"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"global"},{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.Authorization","pt":"msg","to":"\"Bearer \" & $$.token","tot":"jsonata"},{"t":"set","p":"headers.Accept","pt":"msg","to":"application/json","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"https://api.preprod.sywa.fr/access-controls/2/attendees","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["bc23a03b.fa0a8"]]},{"id":"bc23a03b.fa0a8","type":"http request","z":"b26325bc.6122d8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":810,"y":220,"wires":[["6a0d7785.a576a8"]]},{"id":"6a0d7785.a576a8","type":"split","z":"b26325bc.6122d8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":950,"y":220,"wires":[["7e7bf58f.ecfd1c","ba414ab7.ea59e8"]]},{"id":"ee3ecafb.5dddf8","type":"debug","z":"b26325bc.6122d8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":280,"wires":[]},{"id":"8094763.a62db88","type":"function","z":"b26325bc.6122d8","name":"DELETE ","func":"var newMsg = {\n\"topic\" : \"DELETE FROM `access_valid` WHERE 1\"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":280,"wires":[["7f94c7eb.f4d0c8"]]},{"id":"3f5e09ad.eada76","type":"Stackhero-MySQL","z":"b26325bc.6122d8","server":"6e6c4c1b.6c0d54","name":"","x":1250,"y":220,"wires":[[]]},{"id":"7f94c7eb.f4d0c8","type":"Stackhero-MySQL","z":"b26325bc.6122d8","server":"6e6c4c1b.6c0d54","name":"","x":430,"y":280,"wires":[["ee3ecafb.5dddf8"]]},{"id":"7e7bf58f.ecfd1c","type":"change","z":"b26325bc.6122d8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"INSERT INTO `access_valid`(`Id`,`lastName`, `firstName`, `projectStatus`, `projectName`, `projectdateEnd`, `projectdateStart`, `employerName`) VALUES ('\"&payload.id&\"','\"&payload.lastName&\"','\"&payload.firstName&\"','\"&payload.project.status&\"','\"&payload.project.name&\"','\"&payload.project.dateEnd&\"','\"&payload.project.dateStart&\"','\"&payload.employer.name&\"')\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":220,"wires":[["3f5e09ad.eada76"]]},{"id":"ba414ab7.ea59e8","type":"debug","z":"b26325bc.6122d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":120,"wires":[]},{"id":"6e6c4c1b.6c0d54","type":"Stackhero-MySQL-Server","name":"","host":"localhost","port":"3306","tls":false,"database":"accesssite"}]
}

I use postman but now i have a new error message. Knowing that if I import this json from node red I have no problem.

{
    "code": "unexpected_error",
    "message": "duplicate id"
}

methodology :

  • I made the flow via node red
  • deploy to test this was good

once validated:

  • I selected the nodes to export and retrieve the json
  • I deleted the flow and redeployed
  • now I try to create a new flow with the copy of the node red export

the final goal being that the action is done directly via node-red and not postman but for the moment it allows me to do my tests and to have the error messages

The code you have posted is not a valid flow for importing.

Try to import into the editor and you will see.

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