HTTP Request နဲ့ Webhook
HTTP Request Node
Section titled “HTTP Request Node”HTTP Request Node ဟာ n8n ရဲ့ Universal API Connector ပါပဲ။ Built-in Integration မရှိတဲ့ ဘယ် 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 | URL ထဲမှာ ?api_key=TOKEN နဲ့ |
| 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 လိုမျိုး 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-form
Production URL: http://localhost:5678/webhook/contact-form
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 ထဲ ထည့်ပို့ချင်ရင် သုံးတယ်။ ခေါ်တဲ့သူကတော့ Workflow ပြီးတဲ့အထိ စောင့်နေရမှာပါ။
Custom Response ပြန်ပို့ခြင်း:
Workflow ထဲမှာ “Respond to Webhook” Node ထည့်ပြီး စိတ်ကြိုက် Response ပြန်နိုင်ပါတယ် -
// 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 ထည့်မှ လက်ခံဖို့ - Query Auth — URL ထဲမှာ
?token=secretပါမှ လက်ခံဖို့ - IP Whitelist — ခွင့်ပြုထားတဲ့ IP တွေကပဲ ဝင်လာလို့ရဖို့ (အသေးစိတ်ကို n8n.io/docs/hosting/configuration/#security တွင် ကြည့်ပါ)
နောက်သင်ခန်းစာမှာ Data Transformation — n8n ထဲက Data တွေကို လိုအပ်သလို ပုံစံပြောင်းလဲတဲ့နည်းကို ဆက်လေ့လာကြပါမယ် ခင်ဗျာ။