Skip to content
GitHub

HTTP Request နဲ့ Webhook

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 လုပ်ဖို့
Methodရည်ရွယ်ချက်
GETData ကို ဖတ်ဖို့ (Read)
POSTData အသစ် ဖန်တီးဖို့ (Create)
PUTData တစ်ခုလုံးကို ပြောင်းလဲဖို့ (Update)
PATCHData ရဲ့ တစ်စိတ်တစ်ပိုင်းကိုပဲ ပြောင်းဖို့
DELETEData ကို ဖျက်ဖို့

လက်တွေ့ ဥပမာ: Public API မှ Data ယူခြင်း

Section titled “လက်တွေ့ ဥပမာ: Public API မှ Data ယူခြင်း”

JSONPlaceholder (Free Test API) ကနေ Todo List ကို လှမ်းဆွဲကြည့်ရအောင် -

Manual Trigger
HTTP Request GET /todos
Code Node Filter: completed only

JSONPlaceholder API ကနေ Completed ဖြစ်တဲ့ Todos တွေကို စစ်ထုတ်ခြင်း

Step 2: HTTP Request Node ကို Configure လုပ်ပါ

Section titled “Step 2: HTTP Request Node ကို Configure လုပ်ပါ”
FieldValue
MethodGET
URLhttps://jsonplaceholder.typicode.com/todos
AuthenticationNone (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"
}
}));
[
{ "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ရည်ရွယ်ချက်
NonePublic API တွေအတွက်
Header AuthAuthorization: Bearer TOKEN ပုံစံ
Basic AuthUsername + Password နဲ့
Query AuthURL ထဲမှာ ?api_key=TOKEN နဲ့
OAuth2n8n 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/json

Webhook — Incoming Data လက်ခံခြင်း

Section titled “Webhook — Incoming Data လက်ခံခြင်း”

Webhook ဆိုတာ n8n ကို Server တစ်ခုအနေနဲ့ ပြောင်းလိုက်ပြီး၊ External Systems တွေကနေ ပို့လာတဲ့ Data တွေကို n8n ကနေ စောင့်ပြီး လက်ခံတဲ့ သဘောပါ -

External System Form / Payment / Git
Webhook Node HTTP POST လက်ခံ
Workflow Continues Processing...

External System → n8n Webhook → Workflow ကို ဆက်အလုပ်လုပ်စေခြင်း

Webhook Workflow ဆောက်ခြင်း

Section titled “Webhook Workflow ဆောက်ခြင်း”
Webhook Trigger
Set Node Format Data
Slack Message

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 လုပ်ကြည့်ရအောင် -

Terminal window
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 ကို လှမ်းခေါ်တဲ့ 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() }}"
}

Production Webhook တွေအတွက် Security အနေနဲ့ အောက်ပါတို့ကို ရွေးချယ်နိုင်ပါတယ် -

  1. Header AuthX-API-Key: secret123 လိုမျိုး Header ထည့်မှ လက်ခံဖို့
  2. Query Auth — URL ထဲမှာ ?token=secret ပါမှ လက်ခံဖို့
  3. IP Whitelist — ခွင့်ပြုထားတဲ့ IP တွေကပဲ ဝင်လာလို့ရဖို့ (အသေးစိတ်ကို n8n.io/docs/hosting/configuration/#security တွင် ကြည့်ပါ)

နောက်သင်ခန်းစာမှာ Data Transformation — n8n ထဲက Data တွေကို လိုအပ်သလို ပုံစံပြောင်းလဲတဲ့နည်းကို ဆက်လေ့လာကြပါမယ် ခင်ဗျာ။