Skip to content

Commit f538fd8

Browse files
committed
doc: Add documentation
1 parent 352f796 commit f538fd8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ LOAD http_client;
1414
### Functions
1515
- `http_get(url)`
1616
- `http_post(url, headers, params)`
17+
- Sends POST request with params encoded as a JSON object
18+
- `http_post_form(url, headers, params)`
19+
- Sends POST request with params being `application/x-www-form-urlencoded` encoded (used by many forms and some APIs)
1720

1821
### Examples
1922
#### GET
@@ -83,6 +86,44 @@ D WITH __input AS (
8386
└────────┴─────────┴─────────────┘
8487
```
8588

89+
#### POST using form encoding(application/x-www-form-urlencoded, not multipart/form-data)
90+
```sql
91+
D WITH __input AS (
92+
SELECT
93+
http_post_form(
94+
'https://httpbin.org/delay/0',
95+
headers => MAP {
96+
'accept': 'application/json',
97+
},
98+
params => MAP {
99+
'limit': 10
100+
}
101+
) AS res
102+
),
103+
__response AS (
104+
SELECT
105+
(res->>'status')::INT AS status,
106+
(res->>'reason') AS reason,
107+
unnest( from_json(((res->>'body')::JSON)->'form', '{"limit": "VARCHAR"}') ) AS features
108+
FROM
109+
__input
110+
)
111+
SELECT
112+
__response.status,
113+
__response.reason,
114+
__response.limit AS limit
115+
FROM
116+
__response
117+
;
118+
┌────────┬─────────┬─────────┐
119+
│ status │ reason │ limit
120+
│ int32 │ varcharvarchar
121+
├────────┼─────────┼─────────┤
122+
200 │ OK │ 10
123+
└────────┴─────────┴─────────┘
124+
```
125+
126+
86127
#### Full Example w/ spatial data
87128
This is the original example by @ahuarte47 inspiring this community extension.
88129

0 commit comments

Comments
 (0)