Thep Excel

OData.Feed – เชื่อมต่อบริการ OData

OData.Feed เชื่อมต่อบริการ OData และดึงข้อมูลจาก OData endpoints ซึ่งมักจะเป็น API ที่มีโครงสร้างมาตรฐาน

=OData.Feed(serviceUri as text, optional headers as nullable record, optional options as any) as any

By ThepExcel AI Agent
12 December 2025

Function Metrics


Popularity
6/10

Difficulty
4/10

Usefulness
6/10

Syntax & Arguments

=OData.Feed(serviceUri as text, optional headers as nullable record, optional options as any) as any

Argument Type Required Default Description
serviceUri text Yes URL ของบริการ OData ที่ต้องการเชื่อมต่อ เช่น https://services.odata.org/V4/TripPinService
headers record Optional null Headers HTTP เพิ่มเติมสำหรับการส่งคำขอ เช่น authentication headers
options record Optional null ตัวเลือกการตั้งค่าเพิ่มเติม เช่น Timeout, ODataVersion, Concurrent เป็นต้น

Examples

เชื่อมต่อ OData service แบบพื้นฐาน
let Source = OData.Feed("https://services.odata.org/V4/TripPinService") in Source
ใช้ OData.Feed เพื่อเชื่อมต่อกับ TripPin OData service และได้รับข้อมูลทั้งหมด
Power Query Formula:

let
    Source = OData.Feed("https://services.odata.org/V4/TripPinService")
in
    Source

Result:

ตารางที่แสดงทรัพยากร (resources) ทั้งหมดที่มีใน OData service นั้น

ระบุ OData version และ timeout
let ServiceUri = "https://services.odata.org/V4/TripPinService", Options = [ ODataVersion = 4, Timeout = 300 ], Source = OData.Feed(ServiceUri, null, Options) i…
ระบุเวอร์ชัน OData และกำหนด timeout เพื่อควบคุมประสิทธิภาพ
Power Query Formula:

let
    ServiceUri = "https://services.odata.org/V4/TripPinService",
    Options = [
        ODataVersion = 4,
        Timeout = 300
    ],
    Source = OData.Feed(ServiceUri, null, Options)
in
    Source

Result:

ตารางข้อมูล OData V4 ที่มี timeout 300 วินาที

เชื่อมต่อด้วย custom headers (authentication)
let ServiceUri = "https://api.example.com/odata", Headers = [Authorization = "Bearer eyJhbGc..."], Source = OData.Feed(ServiceUri, Headers, null) in Source
ใช้ custom headers เพื่อส่งผ่าน API token หรือ bearer token สำหรับการยืนยันตัวตน
Power Query Formula:

let
    ServiceUri = "https://api.example.com/odata",
    Headers = [Authorization = "Bearer eyJhbGc..."],
    Source = OData.Feed(ServiceUri, Headers, null)
in
    Source

Result:

ข้อมูลจาก OData service ที่ต้องการ authentication

เชื่อมต่อ SharePoint Online list
let ServiceUri = "https://tenant.sharepoint.com/sites/sitename/_api/v2.0", Source = OData.Feed(ServiceUri, [#"Authorization" = "Bearer " & token]) in Source
เชื่อมต่อ SharePoint Online เพื่อดึงข้อมูลจาก Lists ผ่าน OData endpoint
Power Query Formula:

let
    ServiceUri = "https://tenant.sharepoint.com/sites/sitename/_api/v2.0",
    Source = OData.Feed(ServiceUri, [#"Authorization" = "Bearer " & token])
in
    Source

Result:

ข้อมูลจาก SharePoint Online

FAQs

OData.Feed ต่างจาก Web.Contents ยังไง?

OData.Feed รองรับ OData protocol โดยเฉพาะ และจัดการ navigation, filtering, sorting อัตโนมัติ ส่วน Web.Contents เป็นเพียง HTTP request ทั่วไป ต้องจัดการ JSON/XML parsing เอง

ต้องใช้ ODataVersion เวอร์ชันไหน?

OData V4 เป็นเวอร์ชันปัจจุบันที่แนะนำ บางบริการเก่าอาจใช้ V3 ตรวจสอบเอกสาร API ของบริการที่คุณเชื่อมต่อ

Timeout default คือเท่าไหร่?

600 วินาที (10 นาที) หากต้องการเปลี่ยน ให้ระบุในตัวเลือก options โดยใช้ Timeout parameter

ต้องใช้ authentication ทุกครั้งไหม?

ขึ้นอยู่กับบริการ OData บางตัวเปิดเข้าถึงได้ทั่วไป บางตัวต้อง API key, Bearer token หรือ credentials

EnableBatch ใช้สำหรับอะไร?

สำหรับการส่งคำขอหลายตัวในการเรียกเดียว (batch request) จะช่วยเมื่อ URI มีความยาวมากเกินไป หรือต้องการ optimize network traffic

Resources & Related

Additional Notes

OData.Feed ใช้สำหรับเชื่อมต่อและเรียกข้อมูลจากบริการ OData (Open Data Protocol) ซึ่งเป็นโปรโตคอลมาตรฐานสำหรับการเข้าถึงข้อมูลผ่าน REST API

ฟังก์ชันนี้มีประโยชน์มากเมื่อคุณต้องการดึงข้อมูลจากบริการคลาวด์หรือเซิร์ฟเวอร์ที่รองรับ OData เช่น SAP, Microsoft Dynamics, SharePoint Online หรืออื่น ๆ

ตัวอย่างการใช้งาน:
– เชื่อมต่อ SharePoint Online เพื่อดึงข้อมูลจาก Lists
– ดึงข้อมูลจาก Microsoft Dynamics 365
– เข้าถึง SAP OData services
– เชื่อมต่อ REST API ที่มี OData support

ส่วนตัวผม มักใช้ OData.Feed เมื่อสร้าง Power BI models ที่ต้อง refresh ข้อมูลจากระบบภายนอกอย่างอัตโนมัติ เพราะมันจัดการ authentication และ data transformation ได้ค่อนข้างสะดวก 😎

Leave a Reply

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