HTTP Request နှင့် Webhook
HTTP Request Node
Section titled “HTTP Request Node”HTTP Request Node သည် n8n ၏ Universal API Connector ဖြစ်သည်။ Built-in Integration မရှိသော API မည်သည့် API ကိုမဆို ဤ Node ဖြင့် ချိတ်ဆက်နိုင်သည်။
HTTP Request Node ကို သုံးရသည့် အချိန်:
- Built-in node မရှိသော Custom API
- REST API endpoints ခေါ်ရန်
- JSON data ပို့/ယူရန်
- API testing ပြုလုပ်ရန်
HTTP Methods
Section titled “HTTP Methods”| Method | ရည်ရွယ်ချက် |
|---|---|
| GET | Data ဖတ်ရန် (Read) |
| POST | Data သစ် ဖန်တီးရန် (Create) |
| PUT | Data တစ်ခုလုံး ပြောင်းရန် (Update) |
| PATCH | Data တစ်ချို့သာ ပြောင်းရန် |
| DELETE | Data ဖျက်ရန် |
လက်တွေ့ ဥပမာ: Public API မှ Data ယူခြင်း
Section titled “လက်တွေ့ ဥပမာ: Public API မှ Data ယူခြင်း”JSONPlaceholder (Free Test API) ကနေ Todo List ဆွဲမည်:
Step 1: Workflow ဆောက်ပါ
Section titled “Step 1: Workflow ဆောက်ပါ”JSONPlaceholder API မှ Completed Todos စစ်ထုတ်ခြင်း
Step 2: HTTP Request Node Configure
Section titled “Step 2: HTTP Request Node Configure”| Field | Value |
|---|---|
| Method | GET |
| URL | https://jsonplaceholder.typicode.com/todos |
| Authentication | None (Public API) |
Step 3: Code Node ဖြင့် Filter
Section titled “Step 3: Code Node ဖြင့် Filter”// Completed todos သာ စစ်ထုတ်ပါconst completedTodos = $input.all().filter(item => item.json.completed === true);
return completedTodos.map(item => ({ json: { id: item.json.id, title: item.json.title, status: "✅ Completed" }}));Expected Output
Section titled “Expected Output”[ { "id": 1, "title": "delectus aut autem", "status": "✅ Completed" }, { "id": 4, "title": "et porro tempora", "status": "✅ Completed" }]Authentication ဖြင့် API ခေါ်ခြင်း
Section titled “Authentication ဖြင့် API ခေါ်ခြင်း”Protected API တွေအတွက် Authentication ထည့်ရသည်:
| Type | ရည်ရွယ်ချက် |
|---|---|
| None | Public API |
| Header Auth | Authorization: Bearer TOKEN |
| Basic Auth | Username + Password |
| Query Auth | ?api_key=TOKEN in URL |
| OAuth2 | n8n Credentials |
Header Authentication ဥပမာ (OpenAI):
HTTP Request: URL: https://api.openai.com/v1/models Authentication: Header Auth Credential: [OpenAI API Credential] → Header: Authorization: Bearer sk-...POST Request ဖြင့် Data ပို့ခြင်း
Section titled “POST Request ဖြင့် Data ပို့ခြင်း”Form Data ကို API ထဲ Submit လုပ်ရာတွင်:
HTTP Request - POST: Method: POST URL: https://api.example.com/users Body: { "name": "{{ $json.name }}", "email": "{{ $json.email }}" } Content-Type: application/jsonWebhook — Incoming Data လက်ခံခြင်း
Section titled “Webhook — Incoming Data လက်ခံခြင်း”Webhook ဆိုတာ n8n ကို Server ပုံပြောင်းပြီး External Systems မှ Data ပို့ရာ n8n ကလက်ခံသည်:
External System → n8n Webhook → Workflow ဆက်ပြေး
Webhook Workflow ဆောက်ခြင်း
Section titled “Webhook Workflow ဆောက်ခြင်း”Goal: Form Submit → Slack Notification
Section titled “Goal: Form Submit → Slack Notification”Step 1: Webhook Trigger Node ထည့်ပါ
Section titled “Step 1: Webhook Trigger Node ထည့်ပါ”Node Search → “Webhook” → ရွေးပါ
Webhook Node ကို Configure လုပ်ရာတွင်:
- HTTP Method: POST
- Path: /contact-form
- Response: Respond with… (Immediately)
Test URL: http://localhost:5678/webhook-test/contact
Production URL: http://localhost:5678/webhook/contact
Step 2: Test URL ဖြင့် Data ပို့ကြည့်ပါ
Section titled “Step 2: Test URL ဖြင့် Data ပို့ကြည့်ပါ”Terminal မှ curl ဖြင့် Test:
curl -X POST http://localhost:5678/webhook-test/contact-form \ -H "Content-Type: application/json" \ -d '{ "name": "Ko Aung", "email": "aung@example.com", "message": "Hello, I need help!" }'Step 3: Webhook Data ကို Format လုပ်ပါ
Section titled “Step 3: Webhook Data ကို Format လုပ်ပါ”n8n Webhook Node ၏ Output:
{ "body": { "name": "Ko Aung", "email": "aung@example.com", "message": "Hello, I need help!" }, "headers": { "content-type": "application/json" }, "query": {}}Data ကိုဖတ်ရာတွင်: {{ $json.body.name }}
Webhook Response
Section titled “Webhook Response”Webhook ကိုခေါ်သော System သို့ Response ပြန်ပို့ရာတွင်:
- Option 1: “Immediately” — 200 OK ကို အမြန်ဆုံး ပြန်ပို့ / Workflow ဆက်ပြေးနေသည် / Form Submit မြန်ဆန်ပါသည်
- Option 2: “When last node finishes” — Workflow ပြီးမှ Response ပြန်ပို့ / Data ကို Response ထဲ ထည့်နိုင်သည် / Caller က Wait နေရသည်
Custom Response ပြန်ပို့ခြင်း:
Workflow ထဲ “Respond to Webhook” Node ထည့်ပြီး:
// Respond to Webhook Node{ "success": true, "message": "Form received! We'll contact you soon.", "ticketId": "TKT-{{ $now.toISO() }}"}Webhook Security
Section titled “Webhook Security”Production Webhook အတွက် Security ရွေးချယ်မှုများ:
- Header Auth — “X-API-Key: secret123” Header ကို Required ဖြစ်အောင် ထည့်ပါ
- Query Auth — URL ထဲ
?token=secretRequired ဖြစ်အောင် ထည့်ပါ - IP Whitelist — n8n.io/docs/hosting/configuration/#security ကို ကြည့်ပါ
နောက်သင်ခန်းစာမှာ Data Transformation — n8n မှာ Data ကို ပုံသဏ္ဍာန် ပြောင်းလဲနည်းကို လေ့လာမည်!