# Help with Admin API Methods

**URL:** <https://discourse.nodered.org/t/help-with-admin-api-methods/43362>\
**Category:** General\
**Created:** [29 March 2021 12:49 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362 "2021-03-29T12:49:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![electronicBlacksmith](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@electronicBlacksmith](https://discourse.nodered.org/u/electronicBlacksmith)\
**Post date:** [29 March 2021 12:49 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/1 "2021-03-29T12:49:02Z")

</div>

First off thank you for taking the time to help me. I am currently lost with what I need to do to import my flows through the command line. I have read through the Admin API Methods [here](https://nodered.org/docs/api/admin/methods/) and this website [here](http://domoticx.com/node-red-example-add-flow-from-commandline/) on examples.

Using the below curl in the command line

```auto
curl -X GET http://localhost:1880/auth/login

```

gives me the output

```auto
{}

```

From what I understand with this is that I do not have active authentication on so I should not have to use any authentication credentials when I use POST.

Now going back to the examples website anytime I follow their "replace all flows from a file" I get a error below

```auto
{"code":"unexpected_error","message":"config.forEach is not a function"}curl: (6) Could not resolve host: application

```

The file has the following information in it.

```auto
[{"id":"bed4fb91.f40858","type":"tab","label":"Sheet 1","disabled":false,"info":""},{"id":"3bcc44ce.14cafc","type":"inject","z":"bed4fb91.f40858","name":"Trigger","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":340,"y":140,"wires":[[]]}]

```

And I am using this curl code on the command line

```auto
curl -X POST http://localhost:1880/flows -H 'content-type: application/json' -d @flows

```

What am I doing wrong? Also my end goal is to take an exported flow file and import the flow over command line so if there is a better way I can do this please let me know.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [29 March 2021 13:25 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/2 "2021-03-29T13:25:19Z")

</div>

> [@electronicBlacksmith](#):
>
> Now going back to the examples website anytime I follow their "replace all flows from a file" I get a error below

Have you contacted the people that provided the example and asked them about it?  
When was their example written?  
What version of Node-red were they using and what version are you using?

Why do you want to import the flow via the command line?

---

<div class="post-metadata">

**Author:** ![electronicBlacksmith](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@electronicBlacksmith](https://discourse.nodered.org/u/electronicBlacksmith)\
**Post date:** [29 March 2021 13:55 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/3 "2021-03-29T13:55:49Z")

</div>

> [@zenofmud](#):
>
> Have you contacted the people that provided the example and asked them about it?  
> When was their example written?  
> What version of Node-red were they using and what version are you using?
> 
> Why do you want to import the flow via the command line?

I have not contacted the people who provided the examples and they do not state what version of node-red they are using.

I want to use the command line so I can automate the node-red installation process on a new machine using a batch file.

---

<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:** [29 March 2021 14:18 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/4 "2021-03-29T14:18:26Z")

</div>

> [@electronicBlacksmith](#):
>
> automate the node-red installation process on a new machine

In that case just place the flows file you want in the .node-red folder.

---

<div class="post-metadata">

**Author:** ![electronicBlacksmith](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@electronicBlacksmith](https://discourse.nodered.org/u/electronicBlacksmith)\
**Post date:** [30 March 2021 20:07 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/5 "2021-03-30T20:07:07Z")

</div>

Thanks Colin for that information and this option seems to work well for me, this brings me to another question. I found the settings.js file under

```auto
%userprofile%\AppData\Roaming\npm\node_modules\node-red\ 

```

and noticed there was a section with the below code.

```auto
// The file containing the flows. If not set, it defaults to flows_<hostname>.json
//flowFile: 'flows.json',

```

I uncommented it like so

```auto
// The file containing the flows. If not set, it defaults to flows_<hostname>.json
flowFile: 'flows.json',

```

and started node-red but it did not load my flows.json file under

```auto
%userprofile%\.node-red

```

am I missing something or modifying the wrong settings.js file?

Thanks again for everyone's help I do appreciate it.

---

<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:** [30 March 2021 20:31 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/6 "2021-03-30T20:31:29Z")

</div>

> [@electronicBlacksmith](#):
>
> am I missing something or modifying the wrong settings.js file?

Look in the node red startup log and it will tell you which settings file it is using. Normally it is in the same directory as the flows file.

---

<div class="post-metadata">

**Author:** ![electronicBlacksmith](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@electronicBlacksmith](https://discourse.nodered.org/u/electronicBlacksmith)\
**Post date:** [31 March 2021 12:22 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/7 "2021-03-31T12:22:33Z")

</div>

Colin,

Thanks again and this was the issue, I took a look at the logs from pm2 and it was using the settings from the same directory as the flows file.

For anyone following along or anyone who finds this in the future I ended up just uncommenting the below code in the settings.js file in the same directory as the flows (run from cmd line `cd %userprofile%\.node-red`)

```auto
// The file containing the flows. If not set, it defaults to flows_<hostname>.json
flowFile: 'flows.json',

```

The reason I did it this way was because I have pm2 running my node-red instance and just creating a generic flows.json makes it easy to copy all the flows over to the new pc.

---

<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:** [14 April 2021 12:23 UTC](https://discourse.nodered.org/t/help-with-admin-api-methods/43362/8 "2021-04-14T12:23:14Z")

</div>

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