What is the HTTP Request Node?
The n8n HTTP Request node is an incredibly versatile node that allows you to send data to or pull data in from any service that has a published API.
You may find yourself needing to use this if n8n doesn’t have a pre-build node for the service you want to connect to, or if a pre-build node doesn’t quite do what you want it to do.
You will find the HTTP Request node in the Core Nodes section.
How to Use the n8n HTTP Request Node
Once you have added the HTTP Request node to your workflow, you can begin to add in the parameters required. Here’s a quick run-down of the options you will see:
- GET: Retrieves data from a specified resource (e.g., fetches data from an API or a webpage).
- POST: Sends data to a server to create or update a resource (e.g., submits a form or uploads data).
- PUT: Updates an existing resource or creates a new one if it doesn’t exist (e.g., replaces the content of a resource).
- PATCH: Partially updates an existing resource (e.g., modifies specific fields of a record without replacing the whole resource).
- DELETE: Removes a specified resource (e.g., deletes a record from a database or API).
- HEAD: Similar to GET but only retrieves headers and metadata, without the response body (e.g., checks if a resource exists or fetches information about it).
- OPTIONS: Describes the communication options available for a resource, often used to determine supported HTTP methods.
The API documentation of the service you are connecting to will tell you what method you need to use to complete the action you are trying to do.
The URL is the URL that that you need to post to.
Authentication is how you will authenticate yourself when making your request. Again, the service provider or the API documentation will tell you what you need to do here.
Send Query Parameters are parameters sent in the URL. For example, if the API documentation says you need to send to https://theapiurl.com/v1?param1=value1¶m2=value2 then you will need send Query Parameters. In this example, you would set these to Name: param1 and Value: value1 etc.
Headers are often required with some API’s. In many cases, n8n will automatically identify and set these for you , but if your request is failing or the API suggests something specific, then you would need to send the expected headers.
Body is where you will send the information required to complete the request. Depending upon how your provider is expecting the data, you can use the pre-defined boxes or you might need to send the data in a JSON string.
If your provider is expecting a basic request such just in a body, then you cab use the pre-defined boxes. If the data is buried into a JSON request, then you will need to send as JSON.
You can add further settings under the Options dropdown such as timeout etc.
Using Data From Previous Nodes
You can drag in data from previous nodes into either the pre-defined boxes or the JSON window. Just be sure that you have Expression selected rather than Fixed above the window or field so this works.
Sending Your Request
Once all of the fields are complete, you are ready to send your request. Always use in test mode first to ensure your request works before setting it to live.