Integrations

Calling REST APIs with GPAL.RESTClient

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();

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.

IRESTClient client = (IRESTClient)GPAL.RESTClient

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

.ToGPALObject();


client

.LoadOpenAPIMap((GPALFile)"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. ExecuteAsync variants are available, and the client's StatusCode holds the HTTP status of the last call for the cases where the status is all you need.

var customer = GPAL.RESTClient

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

.WithEndpoint("/v1/customers")

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

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

.Execute<Customer>();

💬 Ask GPAL