HTTP Request Node
The HTTP Request Node in FlowAI is a fundamental component used for sending network requests. It supports common HTTP methods (GET, POST, PUT, DELETE, etc.) and allows easy interaction with various Web APIs.
Node Configuration
Basic Settings
-
Node Name
- Set a descriptive name, such as “Get Weather” or “Send Data.”
- Other nodes can reference its result through this name.
- It is recommended to use a name that reflects the function for easier maintenance.
-
HTTP Address Two configuration options:
- From Variable: Obtain the URL from another node (using this mode, you need to connect this node after others).
- Direct Input: Manually enter a fixed URL.
-
Request Method Supports standard HTTP methods:
- GET: Retrieve Data
- POST: Create Data
- PUT: Update Data
- DELETE: Delete Data
-
Request Headers
- You can add custom request headers.
- Often used for authentication or specifying content type.
- Format as key-value pairs.
Node Output
The node outputs two main items:
$HTTPNodeName.body
: The response body content.$HTTPNodeName.status
: The HTTP status code.
Usage Examples
Get UUID Example
Let’s retrieve a UUID by calling httpbin.org’s API:
-
Node Configuration
HTTP Address: https://httpbin.org/uuidRequest Method: GETRequest Headers: None -
Expected Output
// Content of $HttpCall1.body{"uuid": "2753d66b-6e6f-4667-8a46-27c4c4f915f6"} -
Status Code
// Content of $HttpCall1.status200
POST Data Example
In this example, we send some data by calling httpbin.org’s POST API:
-
Node Configuration
HTTP Address: https://httpbin.org/postRequest Method: POSTRequest Headers:key: Content-Typevalue: application/jsonRequest Body:{"name": "Zhang San","age": 25,"message": "$InputNode.message"} -
Expected Output
// Content of $HttpCall1.body{"args": {},"data": "{\"name\":\"Zhang San\",\"age\":25,\"message\":\"Hello World\"}","files": {},"form": {},"headers": {"Content-Type": "application/json","Content-Length": "54","Host": "httpbin.org"},"json": {"name": "Zhang San","age": 25,"message": "Hello World"},"url": "https://httpbin.org/post"} -
Status Code
// Content of $HttpCall1.status200
In this example, we:
- Selected the POST method, which enables the “Request Body” input box.
- Set the Content-Type header to application/json.
- Used the variable reference
$InputNode.message
, which will be replaced by the actual input value.
Generic API Calling Process
[HTTP Request] --------> [JSON Processing] --------> [Data Display] | | | | | | Fetch raw data Parse JSON data Display processed result
Precautions
Best Practices
-
Error Handling
- Check the status code to confirm if the request was successful.
- Handle exceptions appropriately.
-
Data Processing
- Use JSON Node to process structured data.
- Utilize the LLM Node to analyze unstructured responses.