> 技术文档 > 【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

https://docs.n8n.io/courses/

文章目录

  • 1. Getting data from the data warehouse
    • Create new workflow
    • Add an HTTP Request node
    • Get the data
    • What\'s next?

1. Getting data from the data warehouse

In this part of the workflow, you will learn how to get data by making HTTP requests with the HTTP Request node.

HTTP Request node:

  • The HTTP Request node is one of the most versatile nodes in n8n. It allows you to make HTTP requests to query data from any app or service with a REST API. You can use the HTTP Request node a regular node orattached to an AI agent to use as a tool.
  • When using this node, you’re creating a REST API call. You need some understanding of basic API terminology and concepts.
  • There are two ways to create an HTTP request: configure the node parameters or import a curl command.

After completing this section, your workflow will look like this:

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

{ \"nodes\": [ { \"parameters\": { \"url\": \"https://internal.users.n8n.cloud/webhook/custom-erp\", \"authentication\": \"genericCredentialType\", \"genericAuthType\": \"httpHeaderAuth\", \"sendHeaders\": true, \"headerParameters\": { \"parameters\": [ {  \"name\": \"unique_id\",  \"value\": \"\" } ] }, \"options\": {} }, \"type\": \"n8n-nodes-base.httpRequest\", \"typeVersion\": 4.2, \"position\": [ 340, -680 ], \"id\": \"ada6becf-c320-41a7-bdca-a842ea3ee769\", \"name\": \"HTTP Request1\", \"credentials\": { \"httpHeaderAuth\": { \"id\": \"sMuanZ4xGobAurzY\", \"name\": \"Nathan\'s ABCorp data warehouse account\" } } }, { \"parameters\": {}, \"type\": \"n8n-nodes-base.manualTrigger\", \"typeVersion\": 1, \"position\": [ 140, -680 ], \"id\": \"ffa1a8ce-1a1e-48c4-8a0d-6af28c0447a5\", \"name\": \"When clicking ‘Execute workflow’\" } ], \"connections\": { \"HTTP Request1\": { \"main\": [ [] ] }, \"When clicking ‘Execute workflow’\": { \"main\": [ [ { \"node\": \"HTTP Request1\", \"type\": \"main\", \"index\": 0 } ] ] } }, \"pinData\": {}, \"meta\": { \"templateCredsSetupCompleted\": true, \"instanceId\": \"24789c4d5aa56ca018d140332e7a43fd37dd7af0409453314fff12dc1aeebfa8\" }}

First, let’s set the scene for building Nathan’s workflow.

Create new workflow

Open your Editor UI and create a new workflow with one of the two possible commands:

  • Select ctrl+alt+n or cmd+option+n on your keyboard.
  • Open the left menu, navigate to Workflows, and select Add workflow.

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

Name this new workflow “Nathan’s workflow.”
【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

The first thing you need to do is get data from ABCorp’s old data warehouse.

In a previous chapter, you used an action node designed for a specific service (Hacker News). But not all apps or services have dedicated nodes, like the legacy data warehouse from Nathan’s company.

Though we can’t directly export the data, Nathan told us that the data warehouse has a couple of API endpoints. That’s all we need to access the data using the HTTP Request node in n8n.

No node for that service?
The HTTP Request node is one of the most versatile nodes, allowing you to make HTTP requests to query data from apps and services. You can use it to access data from apps or services that don’t have a dedicated node in n8n.

Add an HTTP Request node

Now, in your Editor UI, add an HTTP Request node like you learned in the lesson Adding nodes. The node window will open, where you need to configure some parameters.

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取
HTTP Request node

This node will use credentials.

Credentials
Credentials are unique pieces of information that identify a user or a service and allow them to access apps or services (in our case, represented as n8n nodes). A common form of credentials is a username and a password, but they can take other forms depending on the service.

In this case, you’ll need the credentials for the ABCorp data warehouse API included in the email from n8n you received when you signed up for this course. If you haven’t signed up yet, sign up here.

In the Parameters of the HTTP Request node, make the following adjustments:

  • Method: This should default to GET. Make sure it’s set to GET.

  • URL: Add the Dataset URL you received in the email when you signed up for this course.
    【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

    https://internal.users.n8n.cloud/webhook/custom-erp
  • Send Headers: Toggle this control to true. In Specify Headers, ensure Using Fields Below is selected.

    • Header Parameters > Name: Enter unique_id.
    • Header Parameters > Value: The Unique ID you received in the email when you signed up for this course.
      【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取
      【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取
  • Authentication: Select Generic Credential Type. This option requires credentials before allowing you to access the data.

    • Generic Auth Type: Select Header Auth. (This field will appear after you select the Generic Credential Type for the Authentication.)

    • Credential for Header Auth: To add your credentials, select + Create new credential. This will open the Credentials window.

    • In the Credentials window, set Name to be the Header Auth name you received in the email when you signed up for this course.

    • In the Credentials window, set Value to be the Header Auth value you received in the email when you signed up for this course.
      【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取
      【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

    • Select the Save button in the Credentials window to save your credentials. Your Credentials Connection window should look like this:

    【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取
    HTTP Request node credentials

Credentials naming:
New credential names follow the “account” format by default. You can rename the credentials by clicking on the name, similarly to renaming nodes. It’s good practice to give them names that identify the app/service, type, and purpose of the credential. A naming convention makes it easier to keep track of and identify your credentials.
【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

Once you save, exit out of the Credentials window to return to the HTTP Request node.

Get the data

Select the Execute step button in the HTTP Request node window. The table view of the HTTP request results should look like this:

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取
HTTP Request node output

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

This view should be familiar to you from the Building a mini-workflow page.

This is the data from ABCorp’s data warehouse that Nathan needs to work with. This data set includes sales information from 30 customers with five columns:

  • orderID: The unique id of each order.
  • customerID: The unique id of each customer.
  • employeeName: The name of Nathan’s colleague responsible for the customer.
  • orderPrice: The total price of the customer’s order.
  • orderStatus: Whether the customer’s order status is booked or still in processing.

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取

What’s next?

Nathan 🙋: This is great! You already automated an important part of my job with only one node. Now instead of manually accessing the data every time I need it, I can use the HTTP Request Node to automatically get the information.

You 👩‍🔧: Exactly! In the next step, I’ll help you one step further and insert the data you retrieved into Airtable.

【n8n教程笔记——工作流Workflow】文本课程(第一阶段)——5.1 构建工作流:从数据仓库获取数据 (Getting data from the data warehouse)_n8n工作流获取