Making HTTP Requests
Functions can call 3rd party HTTP servers to get additional information for your webhook or just make an API call and end function execution.
Functions can make multiple HTTP request calls to any external server. Some of the uses cases:
Call 3rd party API to get additional authentication tokens before forwarding request.
Send data to the external service directly, without relying on the webhook.
Get additional data to the function so it can dynamically mutate the payload.
Using HTTP package
To make an HTTP request from Lua function, import ‘http’ package:
Specify request body
You can also make a POST, PUT, DELETE requests to a 3rd party APIs:
Reading response body
To read response body:
Query, headers, timeout
To specify query, timeout and headers:
Batch requests
To send multiple requests asynchronously, create a table containing the requests and call the http.request_batch
method:
Since all requests are launched asynchronously,
HTTP package API reference
http.delete(url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.get(url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.head(url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.patch(url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.post(url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.put(url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.request(method, url [, options])
Attributes
Options
Returns
http.response or (nil, error message)
http.request_batch(requests)
Attributes
Returns
[http.response] or ([http.response], [error message])
http.response
The http.response
table contains information about a completed HTTP request.
Attributes
Last updated