Thep Excel

WebMethod.Type – ระบุ HTTP Method สำหรับ Custom Connector

WebMethod.Type เป็นชุดค่าคงที่สำหรับระบุ HTTP method (GET/POST/PUT/DELETE/PATCH/HEAD) โดยค่าพวกนี้จะถูกใช้ในบริบทของ Custom Connector เพื่อกำหนดว่า “คำขอ HTTP” ต้องการทำอะไรกับปลายทาง เช่น ดึงข้อมูล (GET) หรือส่งข้อมูล (POST)

=WebMethod.Get | WebMethod.Post | WebMethod.Put | WebMethod.Delete | WebMethod.Patch | WebMethod.Head

By ThepExcel AI Agent
4 December 2025

Function Metrics


Popularity
4/10

Difficulty
2/10

Usefulness
4/10

Syntax & Arguments

=WebMethod.Get | WebMethod.Post | WebMethod.Put | WebMethod.Delete | WebMethod.Patch | WebMethod.Head

How it works

กำหนด Method ของคำขอ API

ใช้ WebMethod.* เพื่อระบุว่าเรียก API แบบ GET/POST/PUT ตามประเภทของงาน เช่น ดึงข้อมูลหรือส่งข้อมูล

Examples

ตัวอย่างที่ 1: เลือก GET เพื่อดึงข้อมูล
let Request = [Method = WebMethod.Get, Url = "https://api.example.com/customers"] in Request[Method]
กำหนด Method เป็น WebMethod.Get แล้วอ่านค่ากลับมาจะได้ "GET" ใช้เป็นส่วนหนึ่งของโครงสร้างคำขอใน Custom Connector
Power Query Formula:

let Request = [Method = WebMethod.Get, Url = "https://api.example.com/customers"] in Request[Method]

Result:

"GET"

ตัวอย่างที่ 2: เลือก POST เพื่อส่งข้อมูล
let Request = [Method = WebMethod.Post, Url = "https://api.example.com/orders", Content = "{ \"id\": 1 }"] in Request[Method]
กำหนด Method เป็น WebMethod.Post เพื่อสื่อว่าเป็นการส่งข้อมูลไปยังปลายทาง (ตัวอย่างนี้เก็บ payload ไว้ในฟิลด์ Content)
Power Query Formula:

let Request = [Method = WebMethod.Post, Url = "https://api.example.com/orders", Content = "{ \"id\": 1 }"] in Request[Method]

Result:

"POST"

ตัวอย่างที่ 3: เลือก PUT หรือ POST ตามเงื่อนไข
let IsUpdate = true, Method = if IsUpdate then WebMethod.Put else WebMethod.Post in Method
ถ้าต้องอัปเดตข้อมูลให้ใช้ WebMethod.Put แต่ถ้าเป็นการสร้างรายการใหม่ให้ใช้ WebMethod.Post โดยตัดสินจากเงื่อนไข
Power Query Formula:

let IsUpdate = true, Method = if IsUpdate then WebMethod.Put else WebMethod.Post in Method

Result:

"PUT"

FAQs

WebMethod.Type ใช้กับ Web.Contents ได้ไหม?

ตามเอกสาร Microsoft Learn ค่ากลุ่ม WebMethod.* ใช้งานได้ในบริบทของ Custom Connector เป็นหลัก ไม่ได้หมายความว่าใช้โดยตรงได้กับทุกฟังก์ชันเว็บทั่วไปใน Power Query

ควรเลือก Method อะไรเมื่อไหร่?

โดยทั่วไป GET ใช้ดึงข้อมูล, POST ใช้ส่งข้อมูลเพื่อสร้างรายการ, PUT ใช้อัปเดต, DELETE ใช้ลบ และ PATCH ใช้อัปเดตบางส่วน แต่ขึ้นกับข้อกำหนดของ API ปลายทางด้วย

Resources & Related

Additional Notes

WebMethod.Type คือชุดค่าคงที่สำหรับระบุ HTTP method (เช่น GET/POST/PUT/DELETE) ในบริบทของการทำ Custom Connector (Power Query M extension) เพื่อกำหนดวิธีส่งคำขอไปยัง API/เว็บเซอร์วิส

Leave a Reply

Your email address will not be published. Required fields are marked *