# Button send msg not working

**URL:** <https://discourse.nodered.org/t/button-send-msg-not-working/94251>\
**Category:** Developing Nodes\
**Tags:** docker\
**Created:** [30 December 2024 11:04 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251 "2024-12-30T11:04:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunnoy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sunnoy/32/97639_2.png) [@sunnoy](https://discourse.nodered.org/u/sunnoy)\
**Post date:** [30 December 2024 11:04 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/1 "2024-12-30T11:04:29Z")

</div>

**k8s-docker-ops.html**

```auto
button: {
            onclick: function() {
        
                
                $.ajax({
                    url: "inject/" + this.id,
                    method: "POST",
                    data: JSON.stringify({
                        msg: {
                            operation: ""
                        }
                    }),
                    contentType: "application/json",
                    success: function(resp) {
                        RED.notify("ok", "success");
                    }
                });
            }
        },

        node.on('input', async function(msg) {
            const operation = msg.operation || '';
            const params = msg.params || {};

```

```
       **k8s-docker-ops.js**

```

```auto
            node.log(`Received operation: ${operation}`);
            node.log(`Parameters: ${JSON.stringify(params)}`);
            node.log(`msg: ${JSON.stringify(msg)}`);

```

**log**

```auto
30 Dec 18:52:59 - [info] [k8s-docker-ops:4e2ca4f113aeebd7] Received operation: 
30 Dec 18:52:59 - [info] [k8s-docker-ops:4e2ca4f113aeebd7] Parameters: {}
30 Dec 18:52:59 - [info] [k8s-docker-ops:4e2ca4f113aeebd7] msg: {"_msgid":"e42659bd820a79de"}

```

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 December 2024 11:26 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/2 "2024-12-30T11:26:45Z")

</div>

Welcome to the forums @sunnoy

Sorry, but I don't recommend you hi-jack core node internals.

The endpoint `inject/{id}` is only for the `inject` node - so if the fundamentals change with it -your node will break.

Instead, create your own endpoint, and handle it internally in your own node

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [30 December 2024 11:26 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/3 "2024-12-30T11:26:58Z")

</div>

Marcus will develop the answer for you, here is the missing code:

> <https://github.com/node-red/node-red/blob/1e8f840993052b16427e2556545fe6ea40a409d1/packages/node_modules/%40node-red/nodes/core/common/20-inject.js#L179-L196>

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 December 2024 11:29 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/4 "2024-12-30T11:29:47Z")

</div>

Use the above as an example (inject node internals)....

BUT for the love of god - dont use `/inject` - use something unique to your node.  
anyone installing your Node will be very unhappy, if you break core nodes

The reason you are not getting data - is that you are trying to hijack the `inject` node - and it some has checks in place (I believe)

Develop your own, and you should get further

---

<div class="post-metadata">

**Author:** ![sunnoy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sunnoy/32/97639_2.png) [@sunnoy](https://discourse.nodered.org/u/sunnoy)\
**Post date:** [31 December 2024 03:05 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/5 "2024-12-31T03:05:12Z")

</div>

tks i have done this

---

<div class="post-metadata">

**Author:** ![sunnoy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sunnoy/32/97639_2.png) [@sunnoy](https://discourse.nodered.org/u/sunnoy)\
**Post date:** [31 December 2024 03:39 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/6 "2024-12-31T03:39:40Z")

</div>

But how do I find the relevant API references, for example RED.httpAdmin.post in the documentation [Node-RED](https://nodered.org/docs/api/modules/v/1.3/node-red.html#.httpAdmin) not in detail

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [31 December 2024 13:37 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/7 "2024-12-31T13:37:49Z")

</div>

> [@sunnoy](#):
>
> But how do I find the relevant API references

Perhaps you are going off-piste somewhat?

Please back up for a second and describe what you are trying to do with your node so that we can help you understand the best way to approach things.

---

<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:** [1 March 2025 13:38 UTC](https://discourse.nodered.org/t/button-send-msg-not-working/94251/8 "2025-03-01T13:38:47Z")

</div>

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