It shows you how to create an HTTP In flow configured with a path of /hello. If you access Node-RED at http://localhost:1880, then you can trigger the HTTP In node by making an HTTP request in http://localhost:1880/hello.
In these examples, 'localhost' refers to the device running Node-RED - and would only work if you typed that into a browser on that same machine.
To access it from other devices on the same network, you would replace localhost with the ip address of the machine.
Ok, I have followed the /hello example, and get the response page up - but how do I update the flow so when that /hello url is called, it invokes/triggers a particular flow to run/execute ?
Actually that should be as well as showing the page, obviously the browser has to show something when the user goes to that page.
Are you sure you have thought this through fully though, what exactly do you want to happen from the users point of view?
Remember that if you are out on the internet then you may well get random hits on your url from bots tralling the internet, so your flow could be triggered at any time.
Also if a user refreshes the page then it will hit it again, and conversely there is the risk that going there in the browser may not hit it at all, the browser may serve it to the user from its cache. There are ways of mitigating that problem though.
Generally it is considered a bad idea to use a url GET to trigger an action, for all the above reasons. You should really use a POST so it cannot be done accidentally. Or some completely different way using Telegram or MQTT or similar.
well a simple way would be to add a wire from that http in node you have to the rest of your flow... then when it is "browsed to" it will trigger the flow... - but as already pointed out if you want something back to the user it MUST go back via the http response node.
As all this is being done on a private network, the url would not be exposed to anything directly from the network.
@colin, regarding your example about dong a POST bing better - how would that work with a flow ? Would that require someone to submit something each time so that the flow to be executed ?
Can you explain exactly what you are expecting the user to do and what should happen in his browser when this it to happen? I still don't fully understand the use case.
Hi @colin, the use case is still the same as above, to provide a way to execute a flow via a url.
My comment was in response to your, as I was curious how POST would work (what would the user do differently), compared to GET as you had said that was a bad idea. I’m not familiar with the differences.
That does not explain everything. How is the user going to hit the url and what do you want to happen in the browser when he does that? That information is crucial in determining fully what needs to be done.
Going back even further, we had massive racks of IBM manuals covering all aspects of the IBM mainframes in use when I started in IT. One of my early roles as an intern was to take all of the outstanding updates and apply them to the ring binders that were the manuals of the time. I learned so much that summer! The team who were meant to do that stuff (the tech support guys) were amazed that I actually wanted to read that stuff
OK, nostalgia mode off, back to normal programming!
The user can execute the url from any application that makes it a hyperlink. The response would simply be a success statement - rendered on the webpage, there is a recipe for that on the site, which I have already created. To avoid confusion my enquiry was just how a POST would work differently to a GET request. Sorry if I am confusing anything.
The only real difference is that with a GET, you can only pass information in the URL itself such as query parameters. With a POST, you submit a message body with headers. So, for example, you could send some JSON.
Of course, a URL is just a string so a GET can be done with any old browser if needed whereas a POST requires something that formats and sends the data.
There are other verbs as well such as DELETE, PATCH, PUT. See:
The http in node in Node-RED doesn't do any information processing no matter what verb you use, But it gathers up all of the info and puts it into the msg in a usable form. Up to you what actions you then take.