Featured

Templates: Repeating the Call a Page Made

The Value You Cannot Write Down

A hotel booking API is a fair example. Its rates call needs a transactionId header, forty hexadecimal characters, minted per session by the page's JavaScript. It is not a cookie, it is different on every load, and it is dead tomorrow. Paste one into a workflow and the call returns an error about an invalid parameter. The same call also needs the room ids for that hotel and the shape of the occupancy object, neither of which the workflow has any way to know. Writing that request by hand means discovering all of it, and rewriting it whenever the site changes. Taking it from the page means never knowing any of it.

// what the page sent, and what a workflow would otherwise have to reproduce

transactionId: 65731871cae58a4c884bd89693829712a423194a

X-Currency: USD

Saver: true


{"hotelCode":"DEHALAAA","checkInDate":"2027-01-17",

"roomIds":["BSTD------","PSUP------","PPRE------"],

"occupancies":[{"adults":2,"children":[]}], ... }

Filter, Template, Token

Name the call with .WithCallFilter and ask for a template. The call blocks until the page makes a matching request, then hands it back as a GPALRequest: address, method, body, and every header the page's own code attached, minus the ones a browser owns and refuses to be told. The last match wins, because a page that calls an endpoint on load and again once the user has settled has settled by the last one. Then name a value with .WithTokenFor and it becomes a numbered blank, filled from a grid one row at a time. The key stays where it is and the value after it is replaced.

browser.GoTo(searchUrl);


browser

.WithCallFilter("/availability-api/stays-by-rooms")

.CaptureCallTemplate(out GPALRequest rates);


rates.WithTokenFor("checkInDate") // becomes {0}

.WithTokenFor("checkOutDate"); // becomes {1}


browser

.WithTokensFrom(nights)

.Fetch(rates)

.SaveTo(ref json);


// "checkInDate":"2027-01-17" what the page sent

// "checkInDate":"{0}" after WithTokenFor

// "checkInDate":"2026-09-19" at fetch time, from the first column of the row

NOTE

A page calls its API when it is ready to, not when the workflow is. Asking for a template waits for that to happen, up to thirty seconds, and hands back null if it never does, so the workflow decides what a missing template means.

Where a Token Fits, and Where You Place It Yourself

WithTokenFor finds a named scalar: a query parameter such as name=value in a path or form body, or a JSON field such as "name": "value". That covers most of what a site's own front end sends. It does not cover a value that is a path segment rather than a parameter, a value inside an array, or a name used twice with different meanings, since every occurrence takes the same token. Nor does it help where a signature or hash covers the parameters, because changing one invalidates the signature and no templating fixes that. None of it is a dead end. Tokens are only text, and .Fetch has always taken them anywhere in a path, parameter, header or body, so a shape this cannot reach is one you write the token into yourself.

// the escape hatch: read the template, place the blank by hand

GPALRequest mine = (GPALRequest)GPAL.Request

.WithPath(captured.Path.Replace("DEHALAAA", "{0}"))

.WithBody(captured.Body)

.WithHttpMethod(HttpVerb.Post);

WARNING

If a parameter is covered by a signature the front end computes, changing it breaks the signature. That is a property of the target rather than a gap in GPAL, and it defeats every replay approach equally.

💬 Ask GPAL