# Nodered & http post node

**URL:** <https://discourse.nodered.org/t/nodered-http-post-node/84108>\
**Category:** General\
**Created:** [29 December 2023 10:01 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108 "2023-12-29T10:01:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [29 December 2023 10:01 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/1 "2023-12-29T10:01:57Z")

</div>

Hello

I am trying to trigger a telegram msg with a http post node from nodered.

I have the following flow:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a48a098f00bd7e21aa777ead7dc46b9ffde43a66.png)

The http node consists of the following:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f03c439dca41f5f7708d74849fcab5d10ed23833.png)

Obviously I have removed the API and chat ID for security reasons. But if I type that same URL into my browser, the message sends to my telegram bot.

When I hit the timestamp in the flow, I get "NO RESPONSE FROM SERVER" under the HTTP node.

Any ideas what I am doing wronG?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [29 December 2023 10:11 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/2 "2023-12-29T10:11:02Z")

</div>

> [@Sirhc](#):
>
> But if I type that same URL into my browser, the message sends to my telegram bot.

> [@Sirhc](#):
>
> Any ideas what I am doing wronG

A browser will perform a GET, you have set POST.

Is there any reason you are not using the already pre build & highly capable [node-red-contrib-telegrambot](https://flows.nodered.org/node/node-red-contrib-telegrambot) nodes?

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [29 December 2023 11:44 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/3 "2023-12-29T11:44:13Z")

</div>

the GET returns a "NO RESPONSE FROM SERVER"

I tried the telegram nodes, but I kept getting errors every time it polled. See below

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47acd2e5f37f17240274fe9b2d11f2f60fed7556.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd0cb50aaf80da8255da269c53c281d88d37eb9c.png)

I have entered the following:

- Bot-name is my bot name
- Token is the HTTP API code provided by Botfather
- Users is my user name
- Chat ID is the ID provided by IDbot

I couldn't figure out why I kept getting this polling error, so I tried the HTTP node since I know I can send messages to the bot from my browser. But that's not working either!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [29 December 2023 11:47 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/4 "2023-12-29T11:47:07Z")

</div>

does your node-red instance have a route to the telegram api?

As i am certain you know, node-red can run in a completely different place to your browser.

for example, node-red could be running in a docker container with no access to the outside world!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 December 2023 12:18 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/5 "2023-12-29T12:18:20Z")

</div>

The url i use for http requests is,  
`https://api.telegram.org/bot1dhdhhrrjjddkkLzFW_525Kmrl-ilr5EfE/sendMessage?chat_id=-5874643834082&text={{payload}}`

You may need to add the https://  
and method get, and ignore payload.

Also check the request node can do a get request to say `https://www.google.com`.

If you are getting errors from telegrambot, it would be best to show them to us. Add debug nodes set to full message object, telegram gives good error messages normally.

Also show how the telegrambot config is set, obviously use fake chat and bot api keys.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [29 December 2023 22:14 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/6 "2023-12-29T22:14:00Z")

</div>

Thanks for the replies. Node red is not running in a docker.

The request to google works fine, I get a bunch of jargon from google.

I tried your url in the http request node with the following options:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c67388ac3f4cd6b44e4e5fb706c4b7124b867599.png)

In the debug node I get the following:

payload: "RequestError ...."  
topic: ""  
statusCode: "ETIMEDOUT"

When I paste that exact same URL in a browser, the message works fine.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 December 2023 23:11 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/7 "2023-12-29T23:11:48Z")

</div>

This flow works fine for me, add your api key and chatid and test

```auto
[{"id":"153ea825a8452766","type":"inject","z":"bf510de9c34b4fc2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":600,"y":320,"wires":[["1f07ee7d.d6edda"]]},{"id":"1f07ee7d.d6edda","type":"http request","z":"bf510de9c34b4fc2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.telegram.org/bot1234567890qwertyuiopasdfghjk/sendMessage?chat_id=-264836494082&text={{payload}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":320,"wires":[["16725a2ced4bf3d4"]]},{"id":"16725a2ced4bf3d4","type":"debug","z":"bf510de9c34b4fc2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":320,"wires":[]}]

```

returns

```auto
{
    "_msgid": "977a59a428ba099f",
    "payload": {
        "ok": true,
        "result": {
            "message_id": 20969,
            "from": {
                "id": 125467896,
                "is_bot": true,
                "first_name": " ******",
                "username": " ********"
            },
            "chat": {
                "id": - ************** ,
                "title": " *********",
                "type": " *********"
            },
            "date": 1703891201,
            "text": "1703891201865"
        }
    },
    "topic": "",
    "statusCode": 200,
    "headers": {
        "server": "nginx/1.18.0",
        "date": "Fri, 29 Dec 2023 23:06:41 GMT",
        "content-type": "application/json",
        "content-length": "237",
        "connection": "keep-alive",
        "strict-transport-security": "max-age=31536000; includeSubDomains; preload",
        "access-control-allow-origin": "*",
        "access-control-allow-methods": "GET, POST, OPTIONS",
        "access-control-expose-headers": "Content-Length,Content-Type,Date,Server,Connection",
        "x-node-red-request-node": "26a69c1a"
    },
    "responseUrl": "https://api.telegram.org/bot *************************/sendMessage?chat_id=-*********** &text=1703891201865",
    "redirectList": [],
    "retry": 0
}

```

If that fails please export your test flow so we can see exactly what you have entered, please alter chatid and api for security.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [30 December 2023 00:30 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/8 "2023-12-30T00:30:53Z")

</div>

Nope did not work.

here is the flow:

```auto
[
    {
        "id": "4bd8072b210bc49c",
        "type": "http request",
        "z": "94e3a7440c826f1f",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.telegram.org/botAPI_KEY_HERE/sendMessage?chat_id=CHAT_ID_HERE&text={{payload}}",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "basic",
        "senderr": false,
        "headers": [],
        "x": 390,
        "y": 140,
        "wires": [
            [
                "21af778c8feed1d3"
            ]
        ]
    },
    {
        "id": "21af778c8feed1d3",
        "type": "debug",
        "z": "94e3a7440c826f1f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 140,
        "wires": []
    },
    {
        "id": "1af5636fbf63f643",
        "type": "inject",
        "z": "94e3a7440c826f1f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 240,
        "y": 140,
        "wires": [
            [
                "4bd8072b210bc49c"
            ]
        ]
    }
]

```

Here is the complete debug message:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/46ef31f5f26506ceea98148e61c2f546b21ac0f1.png)

Again, when I copy that exact link into my browser, the message sends ☹

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 December 2023 00:36 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/9 "2023-12-30T00:36:24Z")

</div>

You did not use my flow and add your api and chat id.

In your test flow you have use basic auth set.

Try my flow and add your bot api key and the chatid in the url, instead of the ones added..

If you want you can send me the api and chatid in a PM so I can test.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [30 December 2023 00:43 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/10 "2023-12-30T00:43:05Z")

</div>

Sorry not sure what happened, here is the flow:

```auto
[
    {
        "id": "153ea825a8452766",
        "type": "inject",
        "z": "185499ce70cfb9ef",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 6260,
        "y": 720,
        "wires": [
            [
                "1f07ee7d.d6edda"
            ]
        ]
    },
    {
        "id": "1f07ee7d.d6edda",
        "type": "http request",
        "z": "185499ce70cfb9ef",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.telegram.org/botAPIKEY/sendMessage?chat_id=CHATID&text={{payload}}",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 6410,
        "y": 720,
        "wires": [
            [
                "16725a2ced4bf3d4"
            ]
        ]
    },
    {
        "id": "16725a2ced4bf3d4",
        "type": "debug",
        "z": "185499ce70cfb9ef",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 6550,
        "y": 720,
        "wires": []
    }
]

```

Here is the debug:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/dd8fcd24da1f57afa5446871365463d46c6c2329.png)

I can send you the actual flow with the API key etc. if you have no other suggestions?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 December 2023 00:52 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/11 "2023-12-30T00:52:04Z")

</div>

I have received your flow and sent you a message to telegram, i get a 200 response and seems to be working fine for me. Did you get 2 messages from me one a timestamp another some text?

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [30 December 2023 02:14 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/12 "2023-12-30T02:14:59Z")

</div>

Yep I got your messages, I have no idea why it's not working on my flow ☹

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 December 2023 02:19 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/13 "2023-12-30T02:19:36Z")

</div>

Strange as you can send http request to google but not telegram url, I can only think is there some form of firewall or DNS issue. The error you receive seems to be from the http node, not your usual error response from telegram.  
What is node-red running on, and what do you receive from the google url if you add it to my flow example.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [30 December 2023 02:24 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/14 "2023-12-30T02:24:26Z")

</div>

I've also tried pinging [api.telegram.org](http://api.telegram.org) from terminal and it pings fine so that would eliminate DNS issue, the host name resolves to the [api.telegram.org](http://api.telegram.org) IP address.

It's not a firewall issue on the machine. I've also checked router logs, nothing shows up there.

Node red is running on ubuntu.

I get the following when I try [www.google.com](http://www.google.com):

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3eec5e5f6515ef9bdfe9dd4d2dbabc2dea18bc34.png)

Also I get the same error response when I try [www.telegram.org](http://www.telegram.org) with the HTTP GET node.

Interestingly enough, I recall this working fine before I upgraded to Ubuntu 22.04 and node.js version 20.10.0. Maybe that has something to do with it?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 December 2023 08:45 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/15 "2023-12-30T08:45:11Z")

</div>

> [@Sirhc](#):
>
> I recall this working fine before I upgraded to Ubuntu 22.04 and node.js version 20.10.0. Maybe that has something to do with it?

May be, I also notice that the google url is not https.  
There does seem to be issues on this and nodejs 20 [ubuntu https issue at DuckDuckGo](https://duckduckgo.com/?q=ubuntu+https+issue&ia=web)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 December 2023 09:21 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/16 "2023-12-30T09:21:26Z")

</div>

Ah it might be an ipv4/ipv6 thing.

Ping telegram, get the ip and use that in the URL.

---

<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:** [30 December 2023 09:22 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/17 "2023-12-30T09:22:41Z")

</div>

Does node20 prioritise ip6 over ip4?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 December 2023 09:29 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/18 "2023-12-30T09:29:10Z")

</div>

Kinda, since node 18. Iirc since v18, node no longer sorts IP address lookups but returns them as is. Can't find the memo tho to back this up

---

<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:** [30 December 2023 09:30 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/19 "2023-12-30T09:30:11Z")

</div>

I think there is a flag somewhere to tell it to return ip4 first

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 December 2023 09:30 UTC](https://discourse.nodered.org/t/nodered-http-post-node/84108/20 "2023-12-30T09:30:53Z")

</div>

> <https://github.com/nodejs/node/issues/40702#issuecomment-958157082>
>
> \### Version
> 
> v17.0.1
> 
> \### Platform
> 
> Darwin Kernel Version 21.1.0: Wed Oct …13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE\_X86\_64 x86\_64
> 
> \### Subsystem
> 
> \_No response\_
> 
> \### What steps will reproduce the bug?
> 
> I'm trying to connect to a micro-service with this piece of code:
> 
> \`\`\`Javascript
> const connect = (host, port) =\> {
> socket = new require('net').Socket();
> socket.connect(port, host)
> .on('connect', () =\> console.log('konected!'))
> .on('error', e =\> console.log(e));
> };
> 
> connect('localhost', 5098);
> \`\`\`
> 
> this prints out:
> \`\`\`bash
> Error: connect ECONNREFUSED ::1:5098
> at TCPConnectWrap.afterConnect \[as oncomplete\] (node:net:1161:16)
> at TCPConnectWrap.callbackTrampoline (node:internal/async\_hooks:130:17) {
> errno: -61,
> code: 'ECONNREFUSED',
> syscall: 'connect',
> address: '::1',
> port: 5098
> }
> \`\`\`
> 
> 
> \### How often does it reproduce? Is there a required condition?
> 
> Since installed node 17
> 
> \### What is the expected behavior?
> 
> No errors.
> 
> \### What do you see instead?
> 
> \`\`\`bash
> Error: connect ECONNREFUSED ::1:5098
> at TCPConnectWrap.afterConnect \[as oncomplete\] (node:net:1161:16) {
> errno: -61,
> code: 'ECONNREFUSED',
> syscall: 'connect',
> address: '::1',
> port: 5098
> }
> \`\`\`
> 
> \### Additional information
> 
> As far a i tested (v14.18.1 and v16.12.0), this only happens in this version of node.

[Next page](https://discourse.nodered.org/t/nodered-http-post-node/84108.md?page=2)
