Help with node-red Admin API Methods

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 and this website here on examples.

Using the below curl in the command line

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

gives me the output


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

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

[{"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

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.

Edit - I have also asked the question on the node-red forums here

I’m not set up to test this myself just now, but one major thing jumps out to me… the big clue is the message ‘Could not resolve host’.

Even though you are using shell on the EPIC or RIO, you still need to use https and you need to use port 443.
On EPIC and RIO we ‘proxy’ Node-RED because by default it is listening on an insecure port (1880) and has no authentication.
(Hint, take a look at the EPIC or RIO firewall settings and note that you don’t see a firewall rule for port 1880).

Change your curl to be https://localhost and see what happens.

Thank you so much for the reply, I also should add that this is not through the EPIC or Rio but on a normal windows pc that is running node-red that is used to communicate with a EPIC.

I also tried adding https instead of http and now get the following error

curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - The token supplied to the function is invalid

Ok, now I am even more confused. (Grin).

You are using curl on a Windows PC to update the Node-RED flows on the Windows PC?
(I am guessing this from the original post where you were using localhost:1880).

Whats the layout of the two devices (PC and EPIC)?
Where are you running curl?
Where are you trying to move the flows from to?

You are using curl on a Windows PC to update the Node-RED flows on the Windows PC?

I am running curl on the windows pc to update the node-red flows on the same PC

Whats the layout of the two devices (PC and EPIC)?

The pc just runs a node-red flow to move data from the EPIC to a SQL database, we used to use datalink but had issues with consistent data flow and node-red has fixed our issues.

Where are you trying to move the flows from to?

I am trying to move the flows from a text file to a new node-red instance. This will be used in a bash file to automate installation of node-red and importing the flow automatically to the newly installed node-red.