RESTClient

Executing Requests

Methods for executing REST API calls - synchronously or asynchronously, with single or chained results, and for checking HTTP status.

Methods for executing REST API calls - synchronously or asynchronously, with single or chained results, and for checking HTTP status.

Execute() runs the configured request synchronously and returns the response as a string. Execute<T>() deserializes the response to a typed object. ExecuteAsync() and ExecuteAsync<T>() are the async variants. ExecuteAndChain() executes and returns the RESTClient instance for continued chaining - useful when a sequence of calls depends on prior results. ExecuteCheckStatus() returns a bool indicating whether the HTTP response was a success status (2xx). GetExecutionResults() retrieves all results from all Execute calls in the current chain as a ResultCollection.

TIP

All Execute variants accept an optional bool publishEvent parameter (default true). Set to false to suppress GPAL event publishing for this call - useful for high-frequency polling calls that would flood the event log.

Examples

GPAL Fluent: High-level fluent C# API

//Execute() is the most common call - it sends the HTTP request and returns the raw response body as a string. The StatusCode property on the client holds the HTTP status code after each Execute call.

// Execute and get string result string result = GPAL.RestClient .WithAPIBase("http://localhost:9222") .WithEndpoint("/api/navigate") .WithParameters(new { url = "https://example.com" }) .Execute(); // Execute typed result var status = GPAL.RestClient .WithAPIBase("http://localhost:9222") .WithEndpoint("/api/status") .Execute<BrowserStatus>(); // Check HTTP success status bool ok = GPAL.RestClient .WithAPIBase("http://localhost:9222") .WithEndpoint("/api/ping") .ExecuteCheckStatus();