REST API Node Uninstall returns 400 every time

#1

Hello! I am currently working on a program that utilizes the Node-RED Admin HTTP API to uninstall custom nodes from a server.

I have run into an issue where each time I attempt a call to DELETE /nodes/mynode, I get a response of 400 with the error message:
{"error":"unexpected_error","message":"Error: Uninstall failed"}.

To give some context, I have a node named "test-uninstall", which I have verified installation of using PowerShell command "npm ls". I make a call to DELETE through my program, but I have made the same request using PowerShell's cURL equivalent as well:
Invoke-RestMethod -Uri http://localhost:1880/nodes/test-uninstall -Method Delete
and received the message I put above. I have also made a request to GET in order to verify that the node is installed, and confirmed that it is:
image

I have gone through debugging for several hours and have also debugged with a coworker of mine, and we have been unable to find what the problem could be. I am curious if this may be a defect with the Node-RED server? If not, what could I be doing wrong? I am happy to provide any additional info that may be required.

I should also note that authorization has been disabled on the server, so that should not be an issue either.

As I just created my account, I am unable to put more pictures in the post but I assume I can put more in replies if needed.

Thanks for the help!

0 Likes

#2

Is the node you are trying to uninstall still in use in the flow ? (Does it have a non-visible config node that may also still be there even if the "visible" nodes have been removed).
Nodes can't be deleted if they are still in use in any way.

0 Likes

#3

What does the Node-RED log show?

0 Likes

#4

The node is not in use by any flow

0 Likes

#5

The Node-RED console does not have any output when the call is made

0 Likes

#6

I see the local property is false. That means it is not installed in the user directory, which in turn means Node-RED cannot remove it.

I would have expected a better error message however.

What version of Node-RED are you using?

How did you install the node in the first place?

0 Likes

#7

I installed the node using NPM on my machine.

The Node-RED version is v0.19.5 with Node.js v8.12.0

0 Likes

#8

How exactly did you install it? In what directory?

0 Likes

#9

It was installed in my windows user directory. Should it be installed directly to the directory of the specific Node-RED server runtime?

0 Likes

#10

When Node-RED starts it logs the user directory. Is that the directory you installed the node in? What specifically is the path?

0 Likes

#11

The user directory is
User directory : \Users\mitchell.adair\.node-red
The package-lock.json file is located at
C:\Users\mitchell.adair
Running npm ls shows the directory as
C:\Users\mitchell.adair
which contains the node "test-uninstall":
+-- test-uninstall@1.0.0 -> C:\Users\mitchell.adair\workspaces\runtime-EclipseApplication\test-uninstall

0 Likes

#12

The node needs to be installed under the Users\mitchell.adair\.node-red directory for the runtime to be able to remove it. This is the directory it would get installed under if the Pallette Manager were used.

1 Like

#13

That does seem to be the problem. I just installed it there, and the API call worked correctly.

Thank you for the help!

1 Like