RESTClient

Workflows, Loops, and Results

Methods for defining reusable REST workflows, looping over conditions, naming results for chained use, and retrieving accumulated execution results.

Methods for defining reusable REST workflows, looping over conditions, naming results for chained use, and retrieving accumulated execution results.

WithWorkflow wraps a sequence of REST calls into a named, reusable block. While loops the workflow as long as a condition is true. Until loops until a condition becomes true. WithResultName assigns a name to the next Execute result so subsequent calls can reference it with FromResult methods instead of storing it in a variable. GetExecutionResults retrieves all named and unnamed results from the current workflow as a ResultCollection.

Examples

GPAL Fluent: High-level fluent C# API

//WithResultName followed by ExecuteAndChain() stores the result and returns the same client for continued chaining. The named result is then available via any WithXxxFromResult method in subsequent calls.

// Loop until the page reaches a certain state GPAL.RestClient .WithAPIBase("http://localhost:9222") .GoTo(GPAL.Url().ForUrl("https://example.com/job/123").ToGPALObject()) .Execute() .Until(() => { string status = GPAL.RestClient .WithAPIBase("http://localhost:9222") .QuerySelector(".status-badge") .Execute(); return status.Contains("Complete"); }); // Name a result for use downstream GPAL.RestClient .WithAPIBase("http://localhost:9222") .QuerySelector("#order-id") .WithResultName("orderId") .ExecuteAndChain() .GoTo(GPAL.Url().ForUrl("https://example.com/order").ToGPALObject()) .WithUrlFromResult("orderId") .Execute();