---
title: WebMethod.Type – ระบุ HTTP Method สำหรับ Custom Connector
url: https://www.thepexcel.com/functions/power-query/enumerations/webmethod-type/
type: function-explainer
program: Power Query
syntax: "WebMethod.Get | WebMethod.Post | WebMethod.Put | WebMethod.Delete | WebMethod.Patch | WebMethod.Head"
date: 2025-12-04
updated: 2025-12-17
scores:
  popularity: 4
  difficulty: 2
  usefulness: 4
---

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

> ชุดค่าคงที่สำหรับกำหนด HTTP method ใน Custom Connector

## คำอธิบาย

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

## Syntax

```excel
WebMethod.Get | WebMethod.Post | WebMethod.Put | WebMethod.Delete | WebMethod.Patch | WebMethod.Head
```

## เคสการใช้งาน

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

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

_เหมาะกับ:_ custom-connector-request

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: เลือก GET เพื่อดึงข้อมูล

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

**ผลลัพธ์:** `"GET"`

กำหนด Method เป็น WebMethod.Get แล้วอ่านค่ากลับมาจะได้ "GET" ใช้เป็นส่วนหนึ่งของโครงสร้างคำขอใน Custom Connector

### 2. ตัวอย่างที่ 2: เลือก POST เพื่อส่งข้อมูล

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

**ผลลัพธ์:** `"POST"`

กำหนด Method เป็น WebMethod.Post เพื่อสื่อว่าเป็นการส่งข้อมูลไปยังปลายทาง (ตัวอย่างนี้เก็บ payload ไว้ในฟิลด์ Content)

### 3. ตัวอย่างที่ 3: เลือก PUT หรือ POST ตามเงื่อนไข

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

**ผลลัพธ์:** `"PUT"`

ถ้าต้องอัปเดตข้อมูลให้ใช้ WebMethod.Put แต่ถ้าเป็นการสร้างรายการใหม่ให้ใช้ WebMethod.Post โดยตัดสินจากเงื่อนไข

## หมายเหตุเพิ่มเติม

ถ้าคุณกำลังทำ Custom Connector มักจะเจอการกำหนดคำขอ HTTP และอาจเกี่ยวข้องกับฟังก์ชันอย่าง WebAction.Request หรือการเรียกปลายทางผ่าน Web.Contents พร้อมกำหนด header ด้วย Web.Headers

## คำถามที่พบบ่อย

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

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

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

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

## ฟังก์ชันที่เกี่ยวข้อง

- [WebAction.Request](https://www.thepexcel.com/functions/power-query/accessing-data-functions/webaction-request/)
- [Web.Contents – ดึงข้อมูลจากเว็บและ REST API](https://www.thepexcel.com/functions/power-query/accessing-data-functions/web-contents/)
- [Web.Headers](https://www.thepexcel.com/functions/power-query/accessing-data-functions/web-headers/)

## แหล่งข้อมูลเพิ่มเติม

- [เอกสาร Microsoft Learn: WebMethod.Type](https://learn.microsoft.com/en-us/powerquery-m/webmethod-type) _(documentation)_

---

_Source: [https://www.thepexcel.com/functions/power-query/enumerations/webmethod-type/](https://www.thepexcel.com/functions/power-query/enumerations/webmethod-type/)_
