Node-Red HTTP Request Node for Beginners

http-requestThe node-red http request node is a core node and can be used for making http requests. It can be used for.

  • Retrieving web pages from a website
  • Making API Request
  • Sending and receiving JSON data to a website or API.
  • etc





HTTP Request Node Settings

Below is a screen shot of the http request node configuration page.

http-request-node

The settings include

  1. The request method -The node supports the GET,POST,PUT and DELETE methods.

The main method is GET which is used for getting a web page.

2. The url of the resource –

URL examples:

  • www.google.com
  • www.mysite.com:8080 #set port
  • https://www.google.com :use ssl

3. Authentication -If the website requires authentication then basic authentication can be done here.

4. SSL– A check box for forcing the connection to use SSL

5. Response – The response from the server can be an

  • UTF-8 String i.e. A standard web page
  • A binary buffer -Binary data
  • A parsed JSON object – Usually used with web APIs. The node will convert JSON data into a JavaScript object.

node-red-http-responses

Programmatically Changing Settings

The request method and the url can also be set in the node or a proceeding node.

htpp-request-node-settings2

To do that you must configure the http request node request method to be set by msg.method and leave the url blank as shown above

You can then use a function or change node to set the method and url by using the msg.method and msg.url properties as shown below.

set-url-method-request-nodeUsage Examples

To help you better use this node I’ve created several videos.

Using The HTTP Request Node -Video 1
In this video tutorial we start with a quick overview of the http protocol and basic request and responses .We start with a basic overview of the node and then use it to get web pages and to process and extract data from web pages.

Using The Node-Red HTTP Request Node -Part 2
In Part 2 we look at using mustache templates in the url request. We look at receiving JSON data from a web API and extracting data elements from it. We also look at setting request headers using authentication headers as an example.

Using The Node-Red HTTP Request node-Part 3 -Post data to a thingsboard MQTT dashboard – In this last video we look at how you post data using the http request node. This is common when working with web APIs. I demonstrate the node by publishing sensor data to a Thingsboard Dashboard.

Related Tutorials and Resources

Facebooktwittergoogle_plusredditpinterestlinkedinmail

3 comments

  1. Steve, I’ll echo Hubert’s comments about your posts being clear, helpful and also a good base to build upon. To Hubert one suggestion I have is to look at the MQTT-Spy program which runs on Windows and Linux and its free. It is really excellent to learn MQTT by seeing exactly what is being sent and to monitor MQTT traffic. The BLYNK program might help with getting stuff on your phone.

  2. Hello Steve,
    all of your explanations are very clear and informative. Thanks for sharing your knowledge with the public.
    I have a question: Do you know of a forum where somebody can ask questions concerning a project of private nature? I am a retired engineer with experience on the 8051-family. For this I wrote many programs using assembler. I am learning more and more each day on MQTT but I did still not find the guidline on “How to set up a system”. My final goal is the collection of data from different sensors, distributed on my property, and also read the 48 bytes of data from my 8051-network, and have all this published on my mobile. This would give me the chance to get infos on what is going on at home when I travel to other countries (there I build sun cookers for poor people).
    Unfortunately is nobody in my area who I could discuss technics matters concerning this issue.
    For your answer many thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *