Velo by Example: HTTP Client

The Http module provides a simple HTTP client for making GET and POST requests.

Include the HTTP module and create an instance.

include "lang/http.vel";

Http http = new Http();

Make a GET request and check the status code.

str response = http.get("https://example.com");
int status = http.statusCode();

Make a POST request with a JSON body.

str body = "{\"key\": \"value\"}";
str result = http.post(
    "https://api.example.com/data",
    body,
    ""
);