---
title: Uri.BuildQueryString – สร้าง URL Query String
url: https://www.thepexcel.com/functions/power-query/uri-functions/uri-buildquerystring/
type: function-explainer
program: Power Query
syntax: Uri.BuildQueryString(query as record) as text
date: 2025-12-12
updated: 2025-12-17
scores:
  popularity: 4
  difficulty: 4
  usefulness: 4
---

# Uri.BuildQueryString – สร้าง URL Query String

> สร้าง URL Query String จากข้อมูล

## คำอธิบาย

Uri.BuildQueryString สร้าง URL Query String จากรายการหรือแถวข้อมูล มีประโยชน์เมื่อต้องสร้าง URL พารามิเตอร์สำหรับการเรียก API

## Syntax

```excel
Uri.BuildQueryString(query as record) as text
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| query | Yes | record |  | Record ที่มี Key-Value pairs |

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: สร้าง Query String

```excel
Uri.BuildQueryString([id = "123", name = "John"])
```

**ผลลัพธ์:** `"id=123&name=John"`

สร้าง Query String จากข้อมูล Record

### 2. ตัวอย่างที่ 2: ใช้กับ API

```excel
"https://api.example.com/search?" & Uri.BuildQueryString([q = "Thailand", limit = "10"])
```

**ผลลัพธ์:** `"https://api.example.com/search?q=Thailand&limit=10"`

สร้าง URL สำหรับเรียก API

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

**Q: สามารถมี spaces ในค่า Query String ได้หรือไม่**

ได้ ฟังก์ชันจะเข้ารหัส (Encode) spaces เป็น %20 โดยอัตโนมัติ

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

- uri-parse

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

- [Microsoft Learn: Uri.BuildQueryString](https://learn.microsoft.com/en-us/powerquery-m/uri-buildquerystring) _(documentation)_

---

_Source: [https://www.thepexcel.com/functions/power-query/uri-functions/uri-buildquerystring/](https://www.thepexcel.com/functions/power-query/uri-functions/uri-buildquerystring/)_
