Integrations

Calling REST APIs with GPAL.RESTClient

GPAL.RESTClient is a fluent HTTP client for calling any REST API. Point it at a base URL, optionally load an OpenAPI/Swagger map so calls against matching paths get their parameters validated against the spec, and execute requests with the same chain-then-act pattern as the rest of GPAL.

Base URL and Endpoints

You point GPAL.RESTClient at a base URL, then specify the endpoint path for each request. Endpoints can be plain strings for any REST API, or named values from GPAL's own built-in endpoint list for browser-automation calls. LoadOpenAPIMap does not change or extend that built-in list -- it adds a separate validation layer on top.

string result;

GPAL.RESTClient

.WithAPIBase("https://api.example.com")

.WithEndpoint("/v1/customers/42")

.Execute(out result);

Loading an OpenAPI Map for Parameter Validation

LoadOpenAPIMap parses an OpenAPI/Swagger spec and builds a validation map keyed by HTTP method and path (e.g. "GET /v1/customers/42"), recording each operation's required and optional parameter names from the spec. When you then call WithEndpoint("/v1/customers/42") with a matching method, GPAL looks up that path in the map and validates your WithParameters values against the spec's parameter list before sending the request. ListOpenAPIEndPoints logs the method/path combinations discovered from the spec, useful while exploring an unfamiliar API for the first time.

GPAL.RESTClient

.WithAPIBase("https://api.example.com")

.LoadOpenAPIMap(GPAL.FileFor("openapi.yaml"))

.ListOpenAPIEndPoints();

WARNING

Like GPALConverter.WithInput, LoadOpenAPIMap has both a string overload (YAML content or a URL) and a GPALFile overload. A bare string is treated as YAML/URL content, not a file path. Use GPAL.FileFor(path) explicitly to load from a local file.

Parameters, Headers, and Typed Results

Parameters and headers are set with a couple of fluent calls before the terminal Execute. By default Execute returns the raw response as a string, but a generic form deserializes it directly into a typed object so you skip the manual parsing step. Async variants and a quick success/failure check are available for the cases where you don't need the response body at all.

var customer = GPAL.RESTClient

.WithAPIBase("https://api.example.com")

.WithEndpoint("/v1/customers")

.WithHeader("Authorization", "Bearer " + token)

.WithParameters(new { name = "Acme Corp" })

.Execute<Customer>();