# REST API Node Uninstall returns 400 every time

**URL:** <https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888>\
**Category:** Core Development\
**Created:** [12 February 2019 17:54 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888 "2019-02-12T17:54:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 17:54 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/1 "2019-02-12T17:54:44Z")

</div>

Hello! I am currently working on a program that utilizes the [Node-RED Admin HTTP API](https://nodered.org/docs/api/admin/methods/) 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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/699a4545dbd757e71c072637fa5420fc0c55616a.png)

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!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 February 2019 18:37 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/2 "2019-02-12T18:37:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 February 2019 18:42 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/3 "2019-02-12T18:42:53Z")

</div>

What does the Node-RED log show?

---

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 18:47 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/4 "2019-02-12T18:47:06Z")

</div>

The node is not in use by any flow

---

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 18:52 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/5 "2019-02-12T18:52:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 February 2019 18:56 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/6 "2019-02-12T18:56:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 18:58 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/7 "2019-02-12T18:58:53Z")

</div>

I installed the node using NPM on my machine.

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 February 2019 19:01 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/8 "2019-02-12T19:01:23Z")

</div>

How exactly did you install it? In what directory?

---

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 19:06 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/9 "2019-02-12T19:06:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 February 2019 19:20 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/10 "2019-02-12T19:20:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 19:27 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/11 "2019-02-12T19:27:10Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 February 2019 19:31 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/12 "2019-02-12T19:31:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mitchwadair](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitchwadair/32/6117_2.png) [@mitchwadair](https://discourse.nodered.org/u/mitchwadair)\
**Post date:** [12 February 2019 19:40 UTC](https://discourse.nodered.org/t/rest-api-node-uninstall-returns-400-every-time/7888/13 "2019-02-12T19:40:03Z")

</div>

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

Thank you for the help!
