월. 7월 28th, 2025

🚀 Welcome, fellow automators! Today, we’re diving deep into the absolute backbone of almost any complex n8n workflow: the HTTP Request Node. If you want your n8n workflows to truly interact with the outside world – be it a custom CRM, a third-party API, or even your own self-hosted service – this is the node you need to master.

Think of n8n as your workflow’s brain, and the HTTP Request node as its mouth and hands, capable of speaking and interacting with virtually any web service on the planet. Without it, your n8n automations would be largely confined to pre-built integrations, limiting their true potential. Let’s unlock that power! ✨


I. What is the HTTP Request Node?

At its core, the n8n HTTP Request node allows your workflow to send and receive data from web services using the HTTP/HTTPS protocol. This means it can:

  • Fetch data: Retrieve information from an API (e.g., weather data, product details, user profiles).
  • Send data: Submit information to an API (e.g., create a new record, update a database entry, post a message).
  • Interact with webhooks: Send custom payloads to trigger other services.

In essence, it’s your universal connector for anything with a web-based API. 🌐


II. Anatomy of the HTTP Request Node: Key Settings Explained ⚙️

Understanding each setting is crucial for effective use. Let’s break them down:

1. Method 🔄

This defines the type of action you want to perform. The most common methods are:

  • GET: 🎣 Used to retrieve data. Think of it like asking a server, “Give me this information.” It typically doesn’t have a request body.
    • Example: Getting a list of users, fetching current stock prices.
  • POST: 📦 Used to send data to create a new resource. Think of it like telling a server, “Here’s some new data; create something with it.” It usually has a request body.
    • Example: Submitting a new form entry, creating a new user account.
  • PUT: 📝 Used to update an existing resource or create one if it doesn’t exist at a specific URL. It typically replaces the entire resource.
    • Example: Updating all fields of a user profile.
  • PATCH: 🤏 Used to partially update an existing resource.
    • Example: Only changing a user’s email address, not their entire profile.
  • DELETE: 🗑️ Used to remove a resource.
    • Example: Deleting a user account, removing an old file.

2. URL 🔗

This is the web address of the API endpoint you want to interact with.

  • Fixed URL: https://api.example.com/users
  • Dynamic URL (using expressions): You can use expressions to insert data from previous nodes, making your requests incredibly flexible.
    • Example: https://api.example.com/users/{{ $json.userId }} where userId comes from an earlier node’s output.

3. Headers 📜

Headers provide additional information about the request or the client making the request.

  • Authentication: Most APIs require an API key or a token in the headers (e.g., Authorization: Bearer YOUR_TOKEN, x-api-key: YOUR_KEY).
  • Content-Type: Specifies the format of the data in the request body (e.g., application/json, application/x-www-form-urlencoded).
  • Accept: Specifies the type of response data the client expects.

4. Query Parameters (Query Params) ❓

These are key-value pairs appended to the URL after a ? and separated by &. They are primarily used with GET requests for filtering, sorting, or pagination.

  • Example: https://api.example.com/products?category=electronics&limit=10
  • In n8n, you’d add category with value electronics and limit with value 10 in the “Query Parameters” section.

5. Body (Request Body) 📦

This is where you send the actual data for POST, PUT, and PATCH requests. The format depends on the Content-Type header.

  • JSON (JavaScript Object Notation): The most common format for modern APIs.
    • Example:
      {
        "name": "John Doe",
        "email": "john.doe@example.com"
      }
    • You can also use expressions here for dynamic data:
      {
        "name": "{{ $json.firstName }} {{ $json.lastName }}",
        "email": "{{ $json.email }}"
      }
  • Form URL Encoded: Similar to how HTML forms submit data.
    • Example: name=John+Doe&email=john.doe%40example.com
  • Multipart/form-data: Used for sending files along with other form data.
    • Example: Uploading an image along with a product description.
  • Raw: For custom body types like XML or plain text.

6. Authentication 🛡️

n8n offers several built-in ways to handle API authentication securely via its “Credentials” system:

  • None: No authentication.
  • Basic Auth: Username and password.
  • API Key: Often sent in headers or query parameters.
  • OAuth2: For services like Google, Slack, etc., which require user consent.
  • Custom Header: For unique header-based authentication schemes.

💡 Best Practice: Always use n8n’s Credentials for storing sensitive information like API keys and tokens. This keeps your secrets out of the workflow definition itself and allows for easy reuse.

7. Response Options ⬇️

  • Response Format:
    • JSON: Automatically parses the response as JSON, making it easy to access data.
    • Binary Data: Useful for downloading files (images, PDFs).
    • String: For plain text responses.
  • Throw Final Node Error: If checked, the workflow will stop and show an error if the HTTP request fails (e.g., 4xx or 5xx status codes). Uncheck for more robust error handling within the workflow.

8. Options (Advanced) 🛠️

  • Timeout: How long to wait for a response before giving up.
  • Follow Redirects: Whether to automatically follow HTTP redirects (e.g., 301, 302).
  • Max Redirects: The maximum number of redirects to follow.
  • Proxy: If your n8n instance needs to make requests through a proxy server.

III. Basic Usage & Common Scenarios 🎯

Let’s walk through some practical examples.

Example 1: Fetching Weather Data (GET Request) ☀️

Scenario: You want to get the current temperature for a specific city from the OpenWeatherMap API.

  1. Add HTTP Request Node.
  2. Method: GET
  3. URL: https://api.openweathermap.org/data/2.5/weather
  4. Query Parameters:
    • q: London (or {{ $json.city }} if the city name comes from a previous node)
    • appid: YOUR_OPENWEATHERMAP_API_KEY (Use an API Key Credential for this!)
    • units: metric (or imperial for Fahrenheit)
  5. Response Format: JSON

Expected Output: A JSON object containing weather details like temperature, humidity, description, etc. You can then use a Set node or a Code node to extract just the main.temp value.

Example 2: Sending a Slack Notification (POST Request) 💬

Scenario: You want to send a custom message to a Slack channel whenever a new event occurs.

  1. Add HTTP Request Node.
  2. Method: POST
  3. URL: Your Slack Incoming Webhook URL (e.g., https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX)
  4. Headers:
    • Content-Type: application/json
  5. Body (JSON):
    {
      "text": "🚨 New event detected! Details: {{ $json.eventName }} at {{ $json.eventTime }}",
      "channel": "#general"
    }

    (Assume eventName and eventTime come from an earlier node’s output).

  6. Response Format: String (Slack usually responds with “ok”).

Expected Output: A message appears in your specified Slack channel.


IV. Advanced Techniques & Best Practices 🚀

Beyond the basics, the HTTP Request node truly shines with advanced configurations.

1. Dynamic URLs & Data with Expressions ✨

As seen in the examples, using {{ $json.propertyName }} (or {{ $('NodeName').item.json.propertyName }} for specific node output) allows you to build incredibly flexible requests. This is fundamental for processing lists of items or fetching details based on previous steps.

  • Scenario: Fetch details for multiple users by their IDs.
    • Workflow: Start -> Item Lists (with user IDs) -> HTTP Request
    • HTTP Request URL: https://api.example.com/users/{{ $json.userId }}
    • n8n will execute the HTTP Request node for each userId provided by the Item Lists node.

2. Robust Error Handling 🚨

APIs can fail. Your workflow needs to gracefully handle these failures.

  • Continue on Fail: Found under “Options” in the HTTP Request node. If checked, the node will still pass output even if the request fails (e.g., a 404 Not Found error). The output will contain error information.
    • Usage: Combine with an IF node or Try/Catch node afterwards.
      • IF Node: Check {{ $json.statusCode }} or {{ $json.error }} to branch your workflow (e.g., if statusCode >= 400, send an error notification; otherwise, process data).
      • Try/Catch Node: This is the most robust method. Wrap your HTTP Request node in a Try block. If it fails, the workflow execution jumps to the Catch block, allowing you to handle the error (e.g., log it, retry, send an alert).

3. Handling Pagination (Iterating through large datasets) 📈

Many APIs return data in chunks (e.g., 100 records at a time) and require multiple requests to get the full dataset.

  • Offset/Limit Pagination:
    1. Make an initial request with limit=100&offset=0.
    2. Check the response for a totalCount or hasMore indicator.
    3. If more data exists, use a Loop over items or a Do Not Stop on Fail loop to increment the offset in subsequent requests until all data is fetched.
  • Cursor-based / Next Link Pagination:
    1. Make an initial request.
    2. The API response provides a next_page_url or a cursor value.
    3. Use a While loop to repeatedly make requests, updating the URL or cursor with the value from the previous response until next_page_url is null or hasMore is false.

4. Uploading Files (Multipart/form-data) 📁

Uploading files through APIs is a common, but slightly more complex, use case.

  1. Prepare the File: Use a node like “Read Binary File” or an upstream node that provides binary data (e.g., a “Webhook” receiving a file upload). The file data will typically be in the data property of a binary item.
  2. HTTP Request Node:
    • Method: POST or PUT
    • Headers: Content-Type: multipart/form-data (n8n usually handles this automatically if you select Form Data for the body).
    • Body: Select Form Data.
      • Add a new field, e.g., file.
      • For its value, use an expression to reference the binary data: ={{ $binary.data.data }} (assuming data is the name of the binary property from the previous node).
      • You might also need to specify the original fileName via an expression like ={{ $binary.data.fileName }}.
    • Add any other form fields (e.g., description, category) as regular text fields.

5. Securely Storing Credentials 🛡️

Always, always, always use n8n’s Credentials feature for API keys, passwords, and tokens.

  • Go to “Credentials” in the n8n UI.
  • Create a new credential (e.g., “API Key” type).
  • Name it (e.g., “MyServiceAPIKey”) and enter the key.
  • In your HTTP Request node, under “Authentication,” select “API Key” and then choose your saved credential.
  • This prevents sensitive data from being exposed in your workflow JSON and makes it reusable across multiple workflows.

V. Practical Use Cases & More Examples 🛠️

Let’s imagine some real-world scenarios where the HTTP Request node is indispensable.

Use Case 1: Automating SEO Link Building Analysis 🔗

  • Goal: Fetch backlink data for a list of URLs from Ahrefs/SEMRush and update a Google Sheet.
  • Workflow:
    1. Google Sheets (Read Sheet) -> List of URLs.
    2. Item Lists (Process each URL individually).
    3. HTTP Request (GET):
      • URL: https://api.ahrefs.com/v3/site-explorer/metrics?target={{ $json.url }}
      • Headers: Authorization: Bearer YOUR_AHREFS_TOKEN (via API Key Credential).
      • Query Params: output=json, mode=exact
      • Response: JSON with backlink count, domain rating, etc.
    4. Set (Extract desired fields from the Ahrefs response).
    5. Google Sheets (Update Row) -> Write extracted data back to the sheet.

Use Case 2: E-commerce Order Processing Automation 🛒

  • Goal: When a new order comes in on Shopify, push it to a custom CRM and notify the shipping department via a simple API call.
  • Workflow:
    1. Shopify (Trigger on New Order).
    2. HTTP Request (POST):
      • URL: https://your-crm.com/api/orders
      • Headers: Content-Type: application/json, Authorization: Bearer YOUR_CRM_TOKEN (CRM API Key Credential).
      • Body (JSON):
        {
          "orderId": "{{ $json.id }}",
          "customerName": "{{ $json.customer.first_name }} {{ $json.customer.last_name }}",
          "totalAmount": "{{ $json.total_price }}",
          "items": "{{ $json.line_items }}"
        }
      • Response: Confirmation from CRM.
    3. HTTP Request (POST) – Shipping Notification:
      • URL: https://shipping-api.internal.com/notify
      • Headers: Content-Type: application/json
      • Body (JSON):
        {
          "type": "new_order",
          "order_id": "{{ $json.id }}",
          "customer_name": "{{ $json.customer.first_name }}",
          "address": "{{ $json.shipping_address.address1 }}"
        }
      • Error Handling: Continue on Fail + If node to check if shipping notification failed and send an email alert.

Use Case 3: Social Media Content Scheduler 🗓️

  • Goal: Automatically post new articles from your CMS to Twitter/LinkedIn.
  • Workflow:
    1. CMS Trigger (New Article Published).
    2. HTTP Request (POST) – Tweet:
      • URL: https://api.twitter.com/2/tweets
      • Headers: Authorization: Bearer YOUR_TWITTER_BEARER_TOKEN (OAuth2 or Custom Credential for Twitter).
      • Body (JSON):
        {
          "text": "New article: {{ $json.title }} Read more: {{ $json.url }} #{{ $json.category }}"
        }
      • Error Handling: If tweet fails, log it or send a notification.
    3. HTTP Request (POST) – LinkedIn Share:
      • URL: https://api.linkedin.com/v2/shares
      • Headers: Authorization: Bearer YOUR_LINKEDIN_ACCESS_TOKEN, Content-Type: application/json (OAuth2 Credential).
      • Body (JSON):
        {
          "owner": "urn:li:person:YOUR_PROFILE_ID",
          "text": { "text": "Check out our latest article: {{ $json.title }}" },
          "distribution": {
            "linkedInTargetAudienceCriteria": {},
            "feedDistribution": "MAIN_FEED"
          },
          "content": {
            "contentEntities": [
              { "entityLocation": "{{ $json.url }}", "thumbnails": [ { "resolvedUrl": "{{ $json.imageUrl }}" } ] }
            ]
          }
        }

Conclusion 🎉

The n8n HTTP Request node is not just a node; it’s a gateway to infinite possibilities for your automation. By understanding its core settings and mastering advanced techniques like dynamic data, error handling, and pagination, you can build incredibly powerful and flexible workflows that connect with virtually any service out there.

Don’t be intimidated by API documentation; embrace it! The more you experiment with this node, the more you’ll realize the true power of n8n. So, go forth, connect, and automate everything! 🚀✨

Happy Automating! G

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다