# Database location

**URL:** <https://discourse.nodered.org/t/database-location/76237>\
**Category:** General\
**Created:** [7 March 2023 14:21 UTC](https://discourse.nodered.org/t/database-location/76237 "2023-03-07T14:21:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LinkView\_Maze](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LinkView\_Maze](https://discourse.nodered.org/u/LinkView_Maze)\
**Post date:** [7 March 2023 14:21 UTC](https://discourse.nodered.org/t/database-location/76237/1 "2023-03-07T14:21:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 March 2023 14:30 UTC](https://discourse.nodered.org/t/database-location/76237/2 "2023-03-07T14:30:17Z")

</div>

You can use the admin api to post a flow [Admin API Methods : Node-RED](https://nodered.org/docs/api/admin/methods/)

---

<div class="post-metadata">

**Author:** ![LinkView\_Maze](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LinkView\_Maze](https://discourse.nodered.org/u/LinkView_Maze)\
**Post date:** [7 March 2023 15:14 UTC](https://discourse.nodered.org/t/database-location/76237/3 "2023-03-07T15:14:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LinkView\_Maze](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LinkView\_Maze](https://discourse.nodered.org/u/LinkView_Maze)\
**Post date:** [7 March 2023 15:44 UTC](https://discourse.nodered.org/t/database-location/76237/4 "2023-03-07T15:44:20Z")

</div>

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](mailto:t%22:%22set%22,%22p%22:%22payload%22,%22pt%22:%22msg%22,%22to%22:%22client_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":"\](https://auth.app.sywa.fr/auth/realms/sywa-preprod/protocol/openid-connect/token%22,%22tot%22:%22str%22%7D%5D,%22action%22:%22%22,%22property%22:%22%22,%22from%22:%22%22,%22to%22:%22%22,%22reg%22:false,%22x%22:300,%22y%22:220,%22wires%22:%5B%5B%2281f4e74d.24eee8%22%5D%5D%7D,%7B%22id%22:%2279c194a9.a950ec%22,%22type%22:%22inject%22,%22z%22:%22b26325bc.6122d8%22,%22name%22:%22%22,%22props%22:%5B%7B%22p%22:%22payload%22%7D,%7B%22p%22:%22topic%22,%22vt%22:%22str%22%7D%5D,%22repeat%22:%22%22,%22crontab%22:%22%22,%22once%22:false,%22onceDelay%22:0.1,%22topic%22:%22%22,%22payload%22:%22%22,%22payloadType%22:%22date%22,%22x%22:130,%22y%22:220,%22wires%22:%5B%5B%22ef9709bf.b95f18%22,%228094763.a62db88%22%5D%5D%7D,%7B%22id%22:%225076216b.6ecc8%22,%22type%22:%22change%22,%22z%22:%22b26325bc.6122d8%22,%22name%22:%22%22,%22rules%22:%5B%7B%22t%22:%22set%22,%22p%22:%22token%22,%22pt%22:%22global%22,%22to%22:%22payload.access_token%22,%22tot%22:%22msg%22%7D,%7B%22t%22:%22set%22,%22p%22:%22token%22,%22pt%22:%22msg%22,%22to%22:%22token%22,%22tot%22:%22global%22%7D,%7B%22t%22:%22set%22,%22p%22:%22headers%22,%22pt%22:%22msg%22,%22to%22:%22%7B%7D%22,%22tot%22:%22json%22%7D,%7B%22t%22:%22set%22,%22p%22:%22headers.Authorization%22,%22pt%22:%22msg%22,%22to%22:%22%5C)"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](https://api.preprod.sywa.fr/access-controls/2/attendees%22,%22tot%22:%22str%22%7D%5D,%22action%22:%22%22,%22property%22:%22%22,%22from%22:%22%22,%22to%22:%22%22,%22reg%22:false,%22x%22:640,%22y%22:220,%22wires%22:%5B%5B%22bc23a03b.fa0a8%22%5D%5D%7D,%7B%22id%22:%22bc23a03b.fa0a8%22,%22type%22:%22http) 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

---

<div class="post-metadata">

**Author:** ![LinkView\_Maze](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LinkView\_Maze](https://discourse.nodered.org/u/LinkView_Maze)\
**Post date:** [10 March 2023 15:00 UTC](https://discourse.nodered.org/t/database-location/76237/5 "2023-03-10T15:00:06Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [10 March 2023 16:51 UTC](https://discourse.nodered.org/t/database-location/76237/6 "2023-03-10T16:51:53Z")

</div>

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

Also show us what you have tried.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 March 2023 17:14 UTC](https://discourse.nodered.org/t/database-location/76237/7 "2023-03-10T17:14:36Z")

</div>

> [@LinkView\_Maze](#):
>
> I tried another approach via postman

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

---

<div class="post-metadata">

**Author:** ![LinkView\_Maze](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LinkView\_Maze](https://discourse.nodered.org/u/LinkView_Maze)\
**Post date:** [11 March 2023 12:23 UTC](https://discourse.nodered.org/t/database-location/76237/8 "2023-03-11T12:23:05Z")

</div>

```auto
{
  "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.

```auto
{
    "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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 March 2023 13:31 UTC](https://discourse.nodered.org/t/database-location/76237/9 "2023-03-11T13:31:33Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e4a4e9171618419bb72b396ab75651611d593ce.png)

Try to import into the editor and you will see.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 May 2023 13:31 UTC](https://discourse.nodered.org/t/database-location/76237/10 "2023-05-10T13:31:45Z")

</div>

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