fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idiom # 174: Make HTTP POST request

See programming-idioms.org:

Code

web.post6 sends an IPv6 POST request to u and returns the response body. Use web.post4 to connect via IPv4 instead. Since the request data must be a Sequence u8, convert your String using utf8. Pass any additional headers as an immutable container.Map. The function automatically adds the Host, Content-Length and User-Agent headers.

The result s is an outcome String. It contains either the response body or an error, (e.g., if the connection fails or the server returns a status code of 400 or higher)

Runnable Example

The example sends the request to an echo service that responds with the received data and headers.

This example cannot be run online since it requires network access. Module web is not part of the base library, and HTTPS requires the native TLS library wolfSSL to be installed, so the example is run as follows:

fz -jvm -modules=web -JLibraries=wolfssl idiom174ex.fz
last changed: 2026-10-14