HTTP Request Node
The HTTP Request node enables making HTTP requests to external APIs and web services with full control over headers, methods, and request body.
Overview
This versatile node supports all standard HTTP methods (GET, POST, PUT, DELETE, PATCH) with comprehensive configuration options for headers, authentication, and request/response handling.
Configuration
Required Parameters
Parameter | Type | Description |
---|---|---|
url | String | Target URL for the request |
method | String | HTTP method (GET, POST, PUT, DELETE, etc.) |
Optional Parameters
Parameter | Type | Default | Description |
---|---|---|---|
headers | Object | Custom headers for the request | |
body | String/Object | null | Request body (for POST, PUT, PATCH) |
timeout | Number | 30000 | Request timeout in milliseconds |
followRedirects | Boolean | true | Follow HTTP redirects |
maxRedirects | Number | 5 | Maximum number of redirects |
auth | Object | null | Authentication configuration |
retries | Number | 0 | Number of retry attempts |
Input Schema
{
"url": "https://api.example.com/users",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer token123",
"User-Agent": "AxonOS/1.0"
},
"body": {
"name": "John Doe",
"email": "john@example.com"
},
"timeout": 10000,
"retries": 2
}
Output Schema
{
"status": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json",
"content-length": "156"
},
"data": {
"id": 123,
"name": "John Doe",
"email": "john@example.com",
"created_at": "2024-01-15T10:30:00Z"
},
"config": {
"url": "https://api.example.com/users",
"method": "POST"
},
"duration": 245
}
Authentication
Bearer Token
{
"auth": {
"type": "bearer",
"token": "your-access-token"
}
}
Basic Authentication
{
"auth": {
"type": "basic",
"username": "user",
"password": "pass"
}
}
API Key
{
"headers": {
"X-API-Key": "your-api-key"
}
}
Examples
GET Request
// Input
{
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET",
"headers": {
"Accept": "application/json"
}
}
// Output
{
"status": 200,
"data": {
"userId": 1,
"id": 1,
"title": "sunt aut facere...",
"body": "quia et suscipit..."
}
}
POST with JSON Body
// Input
{
"url": "https://httpbin.org/post",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": {
"title": "New Post",
"content": "This is a new post"
}
}
File Upload (Multipart)
// Input
{
"url": "https://httpbin.org/post",
"method": "POST",
"headers": {
"Content-Type": "multipart/form-data"
},
"body": {
"file": "@/path/to/file.pdf",
"description": "Document upload"
}
}
GraphQL Query
// Input
{
"url": "https://api.github.com/graphql",
"method": "POST",
"headers": {
"Authorization": "Bearer ghp_xxxx",
"Content-Type": "application/json"
},
"body": {
"query": "{ viewer { login } }"
}
}
Error Handling
The node handles various error scenarios:
Status Code | Description | Action |
---|---|---|
400-499 | Client errors | Returns error with response body |
500-599 | Server errors | Retries if configured, then returns error |
Timeout | Request timeout | Retries if configured |
Network | Connection failed | Retries if configured |
Error Response Format
{
"error": true,
"status": 404,
"statusText": "Not Found",
"message": "Resource not found",
"data": {
"error": "User with ID 999 does not exist"
}
}
Advanced Features
Custom Retry Logic
{
"retries": 3,
"retryDelay": 1000,
"retryOn": [408, 429, 500, 502, 503, 504]
}
Request Interceptors
{
"interceptors": {
"request": "function(config) { /* modify request */ }",
"response": "function(response) { /* process response */ }"
}
}
Proxy Configuration
{
"proxy": {
"host": "proxy.company.com",
"port": 8080,
"auth": {
"username": "proxy-user",
"password": "proxy-pass"
}
}
}
Best Practices
- Timeout Settings: Always set appropriate timeouts for external requests
- Error Handling: Implement proper error handling for all status codes
- Rate Limiting: Respect API rate limits and implement backoff strategies
- Security: Store credentials securely, use HTTPS when possible
- Logging: Log requests for debugging but avoid sensitive data
- Caching: Cache responses when appropriate to reduce API calls
Performance Tips
- Use connection pooling for multiple requests to the same host
- Implement request caching for frequently accessed data
- Set appropriate timeout values to avoid hanging requests
- Use streaming for large file downloads
- Compress request bodies when supported
Related Nodes
- GraphQL Client - Specialized GraphQL requests
- Webhook Receiver - Handle incoming webhooks
- Rate Limiter - Control request frequency
Troubleshooting
Common Issues
-
CORS Errors
- Add appropriate CORS headers
- Use proxy for cross-domain requests
-
SSL Certificate Issues
- Verify certificate validity
- Configure certificate validation
-
Authentication Failures
- Check token expiration
- Verify authentication method
-
Request Size Limits
- Check API payload limits
- Use streaming for large files