feat: Initial v0.9 release with API Key authentication
## v0.9.20260325_144654 ### Features - API Key Authentication System - Job Worker System - V2 Backup Versioning ### Bug Fixes - get_processor_results_by_job column mapping Co-authored-by: OpenCode
This commit is contained in:
245
docs/N8N_HTTP_REQUEST_GUIDE.md
Normal file
245
docs/N8N_HTTP_REQUEST_GUIDE.md
Normal file
@@ -0,0 +1,245 @@
|
||||
# n8n HTTP Request Node 設定指南
|
||||
|
||||
> **API URL 說明**:
|
||||
> - **本地測試**: `http://localhost:3002`
|
||||
> - **n8n workflow**: `https://api.momentry.ddns.net`
|
||||
>
|
||||
> ⚠️ 在 n8n 中請使用 `api.momentry.ddns.net`,不要使用 `localhost:3002`
|
||||
|
||||
---
|
||||
|
||||
## 錯誤排除
|
||||
|
||||
### 錯誤訊息: "Your request is invalid or could not be processed by the service"
|
||||
|
||||
這通常表示 HTTP Request Node 的設定不正確。
|
||||
|
||||
---
|
||||
|
||||
## 正確的 Node 設定方式
|
||||
|
||||
### 方法 1: 使用 JSON Body (推薦)
|
||||
|
||||
```
|
||||
Node: HTTP Request
|
||||
├── URL: https://api.momentry.ddns.net/api/v1/n8n/search
|
||||
├── Method: POST
|
||||
├── Authentication: None
|
||||
├── Send Body: ✓ (checked)
|
||||
├── Content Type: JSON
|
||||
├── Body:
|
||||
│ {
|
||||
│ "query": "={{ $json.query }}",
|
||||
│ "limit": "={{ $json.limit }}"
|
||||
│ }
|
||||
└── Options: (empty)
|
||||
```
|
||||
|
||||
### 方法 2: 使用 Raw Body + Headers
|
||||
|
||||
```
|
||||
Node: HTTP Request
|
||||
├── URL: https://api.momentry.ddns.net/api/v1/n8n/search
|
||||
├── Method: POST
|
||||
├── Authentication: None
|
||||
├── Send Body: ✓ (checked)
|
||||
├── Specify Body: Using JSON
|
||||
├── JSON Body:
|
||||
│ {
|
||||
│ "query": "charade",
|
||||
│ "limit": 3
|
||||
│ }
|
||||
├── Send Headers: ✓ (checked)
|
||||
└── Header Parameters:
|
||||
└── Content-Type: application/json
|
||||
```
|
||||
|
||||
### 方法 3: 最簡單的 Hardcoded 測試
|
||||
|
||||
```
|
||||
Node: HTTP Request
|
||||
├── URL: https://api.momentry.ddns.net/api/v1/n8n/search
|
||||
├── Method: POST
|
||||
├── Send Body: ✓
|
||||
├── Content Type: JSON
|
||||
└── Body:
|
||||
{
|
||||
"query": "charade",
|
||||
"limit": 3
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 常見錯誤與解決
|
||||
|
||||
### ❌ 錯誤 1: Body 格式錯誤
|
||||
|
||||
**錯誤設定:**
|
||||
```
|
||||
Body Parameters:
|
||||
query = {{ $json.query }}
|
||||
limit = {{ $json.limit }}
|
||||
```
|
||||
|
||||
**正確設定:**
|
||||
```
|
||||
Content Type: JSON
|
||||
Body:
|
||||
{
|
||||
"query": "={{ $json.query }}",
|
||||
"limit": "={{ $json.limit }}"
|
||||
}
|
||||
```
|
||||
|
||||
### ❌ 錯誤 2: 缺少引號
|
||||
|
||||
**錯誤:**
|
||||
```json
|
||||
{
|
||||
query: "charade",
|
||||
limit: 3
|
||||
}
|
||||
```
|
||||
|
||||
**正確:**
|
||||
```json
|
||||
{
|
||||
"query": "charade",
|
||||
"limit": 3
|
||||
}
|
||||
```
|
||||
|
||||
### ❌ 錯誤 3: URL 錯誤
|
||||
|
||||
**錯誤:**
|
||||
```
|
||||
URL: http://localhost:3002/api/v1/n8n/search
|
||||
```
|
||||
|
||||
**正確:**
|
||||
```
|
||||
URL: https://api.momentry.ddns.net/api/v1/n8n/search
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 測試步驟
|
||||
|
||||
### 步驟 1: 創建最簡單的測試
|
||||
|
||||
1. 新建工作流程
|
||||
2. 添加 **Manual Trigger** Node
|
||||
3. 添加 **HTTP Request** Node
|
||||
4. 設定如下:
|
||||
- URL: `https://api.momentry.ddns.net/api/v1/n8n/search`
|
||||
- Method: POST
|
||||
- Send Body: ✓
|
||||
- Content Type: JSON
|
||||
- Body: `{"query": "charade", "limit": 2}`
|
||||
|
||||
### 步驟 2: 執行測試
|
||||
|
||||
1. 點擊 **Execute Workflow**
|
||||
2. 查看 HTTP Request Node 的輸出
|
||||
3. 應該看到 JSON 回應
|
||||
|
||||
### 步驟 3: 確認成功
|
||||
|
||||
成功的回應應該包含:
|
||||
```json
|
||||
{
|
||||
"query": "charade",
|
||||
"count": 2,
|
||||
"hits": [...]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 直接複製使用的工作流程 JSON
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Video Search - Working Example",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [250, 300]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "https://api.momentry.ddns.net/api/v1/n8n/search",
|
||||
"method": "POST",
|
||||
"sendBody": true,
|
||||
"contentType": "json",
|
||||
"body": {
|
||||
"query": "charade",
|
||||
"limit": 3
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"name": "Search Video API",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.1,
|
||||
"position": [450, 300]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Search Video API",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**導入方式:**
|
||||
1. 在 n8n UI 中,點擊左上角的 Menu
|
||||
2. 選擇 **Import from File**
|
||||
3. 選擇上面的 JSON 文件
|
||||
|
||||
---
|
||||
|
||||
## 驗證 API 可用性
|
||||
|
||||
在終端機測試:
|
||||
```bash
|
||||
curl -X POST https://api.momentry.ddns.net/api/v1/n8n/search \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"query":"charade","limit":2}'
|
||||
```
|
||||
|
||||
如果 curl 成功但 n8n 失敗,問題在於 n8n HTTP Request Node 的設定。
|
||||
|
||||
---
|
||||
|
||||
## 需要幫助?
|
||||
|
||||
如果仍然無法工作:
|
||||
1. 開啟工作流程
|
||||
2. 點擊 HTTP Request Node
|
||||
3. 點擊右上角的 **Execute Node** 單獨執行
|
||||
4. 查看錯誤訊息的詳細內容
|
||||
5. 檢查 Network tab 中的 request/response
|
||||
|
||||
---
|
||||
|
||||
## 相關文件
|
||||
|
||||
- [API_INDEX.md](./API_INDEX.md) - 文件總覽(起點)
|
||||
- [API_N8N_GUIDE.md](./API_N8N_GUIDE.md) - n8n 快速使用指南
|
||||
- [API_ENDPOINTS.md](./API_ENDPOINTS.md) - 端點完整說明
|
||||
Reference in New Issue
Block a user