Request

Recording What the Page Calls

CaptureCalls(bool) starts and stops recording. CaptureCalls(out List<GPALCall>) hands back everything recorded so far and keeps recording. WithCallFilter(string) narrows recording to calls whose url holds that fragment, which is how you get past the analytics and font requests to the one call that matters. ClearCapturedCalls forgets everything recorded so far without stopping the recording, which is how a workflow says "from here on" before the step it actually cares about. Each GPALCall carries Url, Method, ResourceType (XHR, Fetch, Document, Script and the rest), PostData for calls that had a body, Initiator (parser, script, preload), Status, and Headers. The headers are the part worth having: what the page's own code added is what its API expects, and it is exactly what a request written by hand leaves out.

NOTE

Status is what the page itself got back, not what you would get. A call the page is already failing at is not an endpoint worth reissuing, and a 0 means nothing came back yet.

Examples

GPAL Fluent: High-level fluent C# API

//Recording is on the browser, not on a selector, because a page calls its API when it is ready to rather than when a workflow asks. Turn it on before the navigation that triggers the call.

// Record everything the page asks for while it works

browser.CaptureCalls(true);

browser.GoTo("https://example.com/search?q=boots");

browser.CaptureCalls(out List<GPALCall> calls);


foreach (GPALCall call in calls)

GPAL.PublishSimpleEvent(GPALEventType.NOTICE,

$"[{call.Status}] [{call.Method}] [{call.ResourceType}] [{call.Url}]");


// Forget the page load and watch only what the next click asks for

browser.ClearCapturedCalls();


// Or narrow to the one endpoint you care about before it happens

browser.WithCallFilter("/api/search").CaptureCalls(true);

💬 Ask GPAL