# The process of installing nodes using the post method

**URL:** <https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332>\
**Category:** General\
**Created:** [19 April 2024 08:44 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332 "2024-04-19T08:44:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [19 April 2024 08:44 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332/1 "2024-04-19T08:44:48Z")

</div>

Hello everyone, I would like to get ideas for a project.  
I want to register a node with .tgz extension from my desktop application on the same local network to node-red on the other device.

Steps:

1. Connecting to the local device via ssh
2. this tgz file will be on my own computer and I will upload it to the other node-red device via ssh (The file path to be uploaded is ".node-red/nodes/xyz.tgz"
3. I need to install the node at the path ".node-red/nodes/xyz.tgz" on this device

I found these in the Node-red documentation.

CURL Code;  
curl -X POST [http://localhost:1880/nodes](http://localhost:1880/nodes) -H "Content-Type: multipart/form-data" -F "tarball=@node-red-contrib-foo-1.0.3.tgz;type=application/ x-compressed-tar;filename=node-red-contrib-foo-1.0.3.tgz"

I want to ask 3 questions regarding this code?

1. Is filename just the filename? Isn't the path to the file included?

2. There is a note in the node-red document saying (Requires permission: nodes.write) for this curl code to work. How should I achieve this?

3. Do I need tokens for this curl code to work? If so, how can I get it?

If you can think of any other ideas, I would appreciate it if you could share them. Generations after us can benefit from it 🙂  
Thank you from now

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [19 April 2024 09:13 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332/2 "2024-04-19T09:13:10Z")

</div>

> [@sercancetin](#):
>
> - Is filename just the filename? Isn't the path to the file included?

filename is just filename, the contents of the file is uploaded using the curl command.

> [@sercancetin](#):
>
> There is a note in the node-red document saying (Requires permission: nodes.write) for this curl code to work. How should I achieve this?

By default the node red use has all permissions, you can basically ignore this.

> [@sercancetin](#):
>
> Do I need tokens for this curl code to work? If so, how can I get it?

If you setup a admin user/password in the settings.js, then yes, you'll need a token.

You can obtain a token using the /auth/token endpoint:

```auto
RED.util.evaluateNodeProperty(cfg.apiPassword, cfg.apiPasswordType,
                                          node, msg, (err, result) => {
              if (err) {
                node.status({fill:"red",shape:"dot",text:"Failed"});
                node.error("error occurred", {...msg, _err: err})
              } else {
                password = result;

                var data = {
                      "client_id": "node-red-admin",
                      "grant_type": "password",
                      "scope": "*",
                      "username": username,
                      "password": password
                }

                import('got').then( (module) => {
                  module.got.post( (cfg.hostUrl || msg.hostUrl) + "/auth/token", {
                    json: data
                  }).then( res => {
                    node.status({
                      fill:"blue",
                      shape:"dot",
                      text:"Sending flow"
                    });

                    var access_token = JSON.parse(res.body).access_token;

                    sendFlow({
                      "Authorization": "Bearer " + access_token
                    }, module.got);

                  }).catch((err) => {
                    node.status({fill:"red",shape:"dot",text:"Failed"});
                    node.error( "error occurred", { ...msg, _err: err });
                  });
                });
              }
            })

```

That code is taken from the [SendFlow](https://cdn.flowhub.org/?fhid=d73d76db3df96ba2&t=0#node/a645a92622a9763e/edit) node from the [introspection](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-introspection) node package.

Full disclosure: I'm the author of that package.

---

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [19 April 2024 10:20 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332/3 "2024-04-19T10:20:04Z")

</div>

İlginiz için teşekkür ederim. Peki curl komutuna örnek verebilir misiniz? Siz nasıl yapardınız mesala bu probleme karşı?

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [19 April 2024 10:41 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332/4 "2024-04-19T10:41:14Z")

</div>

I take this to be:

> Thank you for your attention. So can you give an example of the curl command? How would you do, for example, against this problem?

No I'm not going to create a curl command since I do this in Node-RED and secondly there is an example at the [documentation for auth/token](https://nodered.org/docs/api/admin/oauth). 🙂

---

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [19 April 2024 10:46 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332/5 "2024-04-19T10:46:43Z")

</div>

You have created a road map. Thank you

---

<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:** [18 July 2024 10:47 UTC](https://discourse.nodered.org/t/the-process-of-installing-nodes-using-the-post-method/87332/6 "2024-07-18T10:47:29Z")

</div>

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