Appearance
03.05 Request Format
📌 At a Glance
| รายการ | รายละเอียด |
|---|---|
| Topic | Request Format |
| Difficulty | ⭐ Beginner |
| Reading Time | 7 นาที |
| Target | Developer |
🎯 Learning Objectives
หลังจากศึกษาหัวข้อนี้แล้ว ผู้อ่านจะสามารถ
- เข้าใจรูปแบบ HTTP Request ของ SISAHYGO API
- กำหนด Header ได้ถูกต้อง
- ส่งข้อมูล JSON ตามมาตรฐานของระบบ
- เตรียม Request สำหรับทุก Endpoint
Overview
SISAHYGO API ใช้มาตรฐาน HTTP Request ร่วมกับ JSON Payload
ทุก Endpoint มีรูปแบบการส่ง Request ที่สอดคล้องกัน ได้แก่
- HTTPS
- API Key
- JSON
- UTF-8 Encoding
Developer สามารถใช้โครงสร้างเดียวกันกับทุก Endpoint โดยเปลี่ยนเฉพาะ URL และ Request Body
Figure 3-5 Standard Request Format
(แทรกรูป Figure 3-5 : Standard Request Format)

Figure 3-5 แสดงองค์ประกอบของ HTTP Request ประกอบด้วย Request Line, HTTP Headers และ JSON Request Body ซึ่งเป็นรูปแบบมาตรฐานที่ใช้กับทุก Endpoint ของ SISAHYGO API
HTTP Request Structure
HTTP Request ประกอบด้วย 3 ส่วนหลัก
| ส่วน | Description |
|---|---|
| Request Line | Method และ Endpoint |
| Headers | Authentication และ Content Type |
| Body | JSON Payload (เฉพาะ POST) |
Standard Headers
ทุก Request ควรกำหนด Header ดังนี้
http
X-API-Key: YOUR_API_KEY
Accept: application/json
Content-Type: application/jsonExample Request
http
POST /api/v1/order-checkings HTTP/1.1
Host: app.sisahygo.online
X-API-Key: sk_live_xxxxxxxxxxxxxxxxx
Accept: application/json
Content-Type: application/jsonExample JSON Body
json
{
"reference_no": "SO2026000123",
"receiver_code": "RCV0001",
"payment_type": "H",
"items": [
{
"product_code": "P0001",
"quantity": 2
}
]
}Request Validation
ก่อนประมวลผล ระบบจะตรวจสอบ
- API Key
- HTTP Method
- Content-Type
- JSON Format
- Required Fields
- Data Type
- Business Rules
หากไม่ผ่าน Validation ระบบจะตอบกลับ Error Response ตามมาตรฐาน
Key Points
| Item | Value |
|---|---|
| Protocol | HTTPS |
| Authentication | API Key |
| Content Type | application/json |
| Character Encoding | UTF-8 |
| Body Format | JSON |
Implementation Notes
- ใช้ UTF-8 Encoding ทุกครั้ง
- Body ต้องเป็น JSON ที่ถูกต้อง
- POST Request ต้องกำหนด
Content-Type: application/json - Header
X-API-Keyเป็นค่าบังคับทุก Endpoint
Best Practices
- Validate JSON ก่อนส่ง
- ใช้ JSON Formatter ระหว่างพัฒนา
- หลีกเลี่ยงการส่ง Field ที่ระบบไม่ได้กำหนด
- ใช้ข้อมูลตามชนิด (Data Type) ที่ระบุใน API Specification
Summary
ทุก Endpoint ของ SISAHYGO API ใช้รูปแบบ Request เดียวกัน ทำให้การพัฒนาระบบเป็นมาตรฐาน ลดความซับซ้อน และช่วยให้สามารถนำโครงสร้างเดิมไปใช้ซ้ำกับทุกบริการของระบบได้
Next Step
➡️ 03.06 Response Format
