Hi @stamer
I've edited your posts to format the code properly as described in this post: How to share code or flow json
The code inside the RED.httpAdmin.post
handler is not tied to any node instance. node
doesn't exist inside the function. You need to identify the node you want to handle the request for as part of the request itself. You can see how the Inject node does it here: https://github.com/node-red/node-red/blob/master/nodes/core/core/20-inject.js#L113-L114
It defines the admin end point like this:
RED.httpAdmin.post("/inject/:id", ...
The :id
part of the url is a parameter that will contain the id of the node. The function can then go lookup that node:
var node = RED.nodes.getNode(req.params.id);
However, that is a reference to the current deployed node in the runtime. If the user has just dragged on their node to the workspace and edited it to provide a user/password, then none of that information will exist in the runtime yet. In that scenario, you'd need to provide the user/password (and any other node configuration information) in the request itself.