Appearance
04.05 Using Postman
📌 At a Glance
| รายการ | รายละเอียด |
|---|---|
| Topic | Using Postman |
| Difficulty | ⭐ Beginner |
| Reading Time | 8 นาที |
| Target | Developer |
🎯 Learning Objectives
หลังจากศึกษาหัวข้อนี้แล้ว ผู้อ่านจะสามารถ
- สร้าง Postman Environment
- กำหนดค่า Environment Variables
- ทดลองเรียก SISAHYGO API ผ่าน Postman
- ตรวจสอบ Request และ Response ได้
Overview
Postman เป็นเครื่องมือที่แนะนำสำหรับการทดสอบ SISAHYGO API เนื่องจากสามารถจัดการ Environment Variables, HTTP Headers และ JSON Response ได้สะดวก
แนะนำให้ทดสอบทุก Endpoint ผ่าน Postman ก่อนเริ่มพัฒนาในภาษาโปรแกรมจริง
Figure 4-5 Using Postman

Figure 4-5 แสดงขั้นตอนการใช้งาน Postman ตั้งแต่การสร้าง Environment การกำหนดตัวแปร การส่ง Request และการตรวจสอบ JSON Response
Step 1 : Create Environment
สร้าง Environment ใหม่
SISAHYGO Productionเพิ่มตัวแปรดังนี้
| Variable | Value |
|---|---|
| base_url | https://app.sisahygo.online/api/v1 |
| api_key | sk_live_xxxxxxxxxxxxxxxxx |
Step 2 : Create Request
Method
http
GETURL
text
{{base_url}}/productsHeaders
http
X-API-Key: {{api_key}}
Accept: application/jsonStep 3 : Send Request
กดปุ่ม Send
หากการเชื่อมต่อสำเร็จ จะได้รับ HTTP 200 OK พร้อมข้อมูลสินค้าในรูปแบบ JSON
Step 4 : Verify Response
ตรวจสอบ
- HTTP Status = 200
- success = true
- code = 200
- data มีข้อมูล
- version = 1.1
Recommended Collection
แนะนำให้สร้าง Collection ดังนี้
text
SISAHYGO API V1.1
├── Master Data
│ ├── GET Products
│ └── GET Receivers
│
├── Transaction
│ └── POST Order Checkings
│
└── Tracking
├── GET Shipments
└── GET Order RejectionsEnvironment Variables
text
base_url
api_keyใช้ Environment Variables แทนการ Hardcode URL หรือ API Key
Key Points
| Item | Recommendation |
|---|---|
| Environment | ใช้ตัวแปรแทนค่าคงที่ |
| API Key | Environment Variable |
| Base URL | Environment Variable |
| Collection | แยกตามหมวด API |
Implementation Notes
- ไม่บันทึก API Key ลงใน Collection ที่แชร์
- Export Environment โดยลบ API Key ก่อน
- ใช้ Collection เดียวกันทั้งทีมพัฒนา
- ตั้งชื่อ Request ให้ตรงกับชื่อ Endpoint
Best Practices
- แยก Collection ตามหมวด API
- ใช้ Environment Variables ทุกครั้ง
- บันทึกตัวอย่าง Response เพื่อใช้ทดสอบ
- ตรวจสอบ HTTP Status และ JSON Response ทุก Request
Summary
Postman เป็นเครื่องมือที่ช่วยให้ Developer สามารถทดสอบ SISAHYGO API ได้อย่างรวดเร็ว ลดเวลาในการตรวจสอบปัญหา และช่วยให้ทีมพัฒนาใช้มาตรฐานเดียวกัน
Next Step
➡️ 04.06 Testing Checklist
