RESTClient

Setup and Configuration

Methods for initializing the RESTClient with an API base URL, endpoint, name, and optional OpenAPI map.

Methods for initializing the RESTClient with an API base URL, endpoint, name, and optional OpenAPI map.

WithAPIBase sets the base URL for all requests - subsequent WithEndpoint calls are appended to this base. WithName assigns a friendly label to the client instance for logging. WithEndpoint either sets a literal endpoint path, or resolves one of GPAL's built-in ApiEndpoint enum values via RESTHelper.Endpoints - this fixed enum is not affected by LoadOpenAPIMap. LoadOpenAPIMap loads an OpenAPI/Swagger definition from a YAML string, URL, or file and builds a validation map (keyed by HTTP method and path) of each operation's required and optional parameters, used to validate WithParameters when calling a matching literal endpoint path. ListOpenAPIEndPoints logs the method/path combinations discovered from the loaded map.

TIP

RESTClient is the interface to the OttoMagic browser automation REST API. It mirrors the Browser class API but operates over HTTP rather than directly controlling the browser. This is the recommended approach for integrating GPAL browser automation with external systems or microservices.

Examples

GPAL Fluent: High-level fluent C# API

//WithAPIBase is required before any Execute call. The OttoMagic REST API base URL is typically http://localhost:9222 when running locally. WithEndpoint appends the specific operation path.

// Basic RESTClient setup var client = GPAL.RestClient .WithAPIBase("http://localhost:9222") .WithName("LocalBrowser") .ToGPALObject(); // Load OpenAPI map and list endpoints GPAL.RestClient .WithAPIBase("http://localhost:9222") .LoadOpenAPIMap(GPAL.FileFor("openapi.yaml")) .ListOpenAPIEndPoints();