@@ -14,6 +14,9 @@ LOAD http_client;
14
14
### Functions
15
15
- ` http_get(url) `
16
16
- ` 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)
17
20
18
21
### Examples
19
22
#### GET
@@ -83,6 +86,44 @@ D WITH __input AS (
83
86
└────────┴─────────┴─────────────┘
84
87
```
85
88
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 │ varchar │ varchar │
121
+ ├────────┼─────────┼─────────┤
122
+ │ 200 │ OK │ 10 │
123
+ └────────┴─────────┴─────────┘
124
+ ```
125
+
126
+
86
127
#### Full Example w/ spatial data
87
128
This is the original example by @ahuarte47 inspiring this community extension.
88
129
0 commit comments