RESTClient

Setup and Configuration

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. WithVerb sets the HTTP method for a call that does not have one of its own. WithHeaders supplies request headers, WithEncoding the content encoding, and WithBytes asks for the response as bytes rather than text. WithReferrer sets the referrer the request is sent with.

NOTE

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.

// the client object first, then the calls on it

IRESTClient client = (IRESTClient)GPAL.RESTClient

.WithAPIBase("http://localhost:9222")

.ToGPALObject();


// Basic RESTClient setup

var client = client

.WithName("LocalBrowser")

.ToGPALObject();


// Load OpenAPI map and list endpoints

client

.LoadOpenAPIMap((GPALFile)"openapi.yaml")

.ListOpenAPIEndPoints();

💬 Ask GPAL