Make HTTP requests to external APIs. Supports all methods, authentication, custom headers, and file uploads.
Overview
The http-request node makes HTTP requests to external services. Use it to:
- Call REST APIs - Fetch data, post updates, integrate with services
- Send webhooks - Notify external systems of events
- Download files - Fetch firmware, configurations, images
- Upload data - Send sensor data to cloud platforms
Unlike http-in (which creates endpoints), http-request is for making outgoing requests to other servers.
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | - | - | Display name for this node in the editor. |
method | string | - | GET | HTTP method: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS. Can be overridden by msg.method. |
url | string | - | - | URL to request. Can be overridden by msg.url. Supports mustache templates. |
tls | config | - | - | TLS configuration for HTTPS requests with custom certificates. |
persist | boolean | - | false | Use persistent HTTP connections (keep-alive). |
insecure | boolean | - | false | Allow connections to servers with invalid TLS certificates. |
authType | string | - | - | Authentication type: "basic", "digest", "bearer", or empty. |
senderr | boolean | - | false | Send errors as output instead of throwing. |
headers | object | - | {} | Default headers to include in requests. |
ret | string | - | txt | Response body format: "txt" (string), "bin" (buffer), "obj" (parsed JSON). |
Inputs
Configure the request dynamically using message properties:
| Property | Type | Description |
|---|---|---|
| msg.url | string | Request URL (overrides node config) |
| msg.method | string | HTTP method (GET, POST, PUT, DELETE, etc.) |
| msg.payload | any | Request body (for POST, PUT, PATCH) |
| msg.headers | object | HTTP headers to include |
| msg.cookies | object | Cookies to send with request |
| msg.followRedirects | boolean | Whether to follow HTTP redirects |
| msg.requestTimeout | number | Request timeout in milliseconds |
Outputs
The node outputs the HTTP response:
Output Message Format
{`{
"payload": ,
"statusCode": 200,
"headers": {
"content-type": "application/json",
"x-ratelimit-remaining": "99"
},
"responseUrl": "https://api.example.com/data",
"redirectList": [],
"_msgid": ""
}`} Authentication
The node supports several authentication methods:
HTTP Basic authentication. Credentials are base64-encoded in the Authorization header.
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= OAuth 2.0 or API token authentication. Set token in node config or msg.headers.
Authorization: Bearer eyJhbGciOiJIUzI1NiIs... Pass API keys in headers or URL query parameters.
// Header
msg.headers = { "X-API-Key": "your-api-key" };
// Query parameter
msg.url = "https://api.example.com/data?api_key=your-key"; Examples
GET Request - Weather API
Fetch current weather data from an external API.
Weather API
Fetches weather data and extracts temperature.
View Flow JSON
[
{
"id": "inject1",
"type": "inject",
"name": "Get Weather",
"payload": "",
"repeat": "300",
"wires": [["http1"]]
},
{
"id": "http1",
"type": "http-request",
"name": "Weather API",
"method": "GET",
"url": "https://api.openweathermap.org/data/2.5/weather?q=London&appid={{env.WEATHER_API_KEY}}&units=metric",
"ret": "obj",
"wires": [["function1"]]
},
{
"id": "function1",
"type": "function",
"name": "Extract Data",
"func": "msg.payload = {\n temperature: msg.payload.main.temp,\n humidity: msg.payload.main.humidity,\n description: msg.payload.weather[0].description,\n city: msg.payload.name\n};\nreturn msg;",
"wires": [["debug1"]]
},
{
"id": "debug1",
"type": "debug",
"name": "Weather"
}
] POST JSON - Send Sensor Data
Post sensor readings to a cloud API.
Cloud Data Upload
Sends sensor data to a REST API endpoint.
View Flow JSON
[
{
"id": "sensor1",
"type": "dht22",
"name": "DHT22",
"pin": 4,
"wires": [["function2"]]
},
{
"id": "function2",
"type": "function",
"name": "Prepare Request",
"func": "msg.url = 'https://api.example.com/v1/readings';\nmsg.headers = {\n 'Content-Type': 'application/json',\n 'X-API-Key': env.get('API_KEY')\n};\nmsg.payload = {\n device_id: 'rpi-001',\n temperature: msg.payload.temperature,\n humidity: msg.payload.humidity,\n timestamp: new Date().toISOString()\n};\nreturn msg;",
"wires": [["http2"]]
},
{
"id": "http2",
"type": "http-request",
"name": "Upload",
"method": "POST",
"ret": "obj",
"wires": [["switch1"]]
},
{
"id": "switch1",
"type": "switch",
"name": "Check Status",
"property": "statusCode",
"rules": [
{"t": "eq", "v": "200"},
{"t": "eq", "v": "201"},
{"t": "else"}
],
"outputs": 3,
"wires": [["debug2"], ["debug2"], ["error1"]]
},
{
"id": "debug2",
"type": "debug",
"name": "Success"
},
{
"id": "error1",
"type": "debug",
"name": "Error"
}
] API with Bearer Token
Call an authenticated API using Bearer token.
Authenticated API Call
Uses Bearer token to access protected API endpoint.
View Flow JSON
[
{
"id": "inject2",
"type": "inject",
"name": "Fetch Data",
"wires": [["function3"]]
},
{
"id": "function3",
"type": "function",
"name": "Set Auth",
"func": "msg.url = 'https://api.example.com/v1/devices';\nmsg.headers = {\n 'Authorization': 'Bearer ' + env.get('API_TOKEN'),\n 'Accept': 'application/json'\n};\nreturn msg;",
"wires": [["http3"]]
},
{
"id": "http3",
"type": "http-request",
"name": "API Call",
"method": "GET",
"ret": "obj",
"wires": [["debug3"]]
},
{
"id": "debug3",
"type": "debug",
"name": "Devices"
}
] File Upload
Upload a file using multipart form data.
Image Upload
Uploads an image file to a storage API.
View Flow JSON
[
{
"id": "file1",
"type": "file-in",
"name": "Read Image",
"filename": "/tmp/capture.jpg",
"format": "buffer",
"wires": [["function4"]]
},
{
"id": "function4",
"type": "function",
"name": "Prepare Upload",
"func": "msg.headers = {\n 'Content-Type': 'image/jpeg',\n 'X-Filename': 'capture_' + Date.now() + '.jpg'\n};\nmsg.url = 'https://storage.example.com/upload';\n// payload is already the file buffer\nreturn msg;",
"wires": [["http4"]]
},
{
"id": "http4",
"type": "http-request",
"name": "Upload",
"method": "POST",
"ret": "obj",
"wires": [["debug4"]]
},
{
"id": "debug4",
"type": "debug",
"name": "Result"
}
] Troubleshooting
Request times out
- Check network connectivity to the target server
- Increase timeout with
msg.requestTimeout = 30000 - Verify firewall allows outbound connections
- Test the URL with curl or a browser first
Getting 401 Unauthorized
- Verify credentials/tokens are correct
- Check the Authorization header format
- Ensure tokens haven't expired
- Debug msg.headers before the request to verify
Response body is empty
- Some APIs return 204 No Content - check statusCode
- Verify the response format setting (txt/bin/obj)
- Check if API requires specific Accept headers
- Debug the full response including headers
SSL/TLS certificate errors
- For self-signed certs, configure TLS settings or enable "ignore SSL"
- Ensure system CA certificates are up to date
- Check certificate hasn't expired
- Verify hostname matches certificate
JSON parse error on response
If using "parsed JSON" return type and the response isn't valid JSON:
- Change return type to "text" and parse manually
- Check response content-type header
- Server may be returning an error page instead of JSON