SendNetworkRequest

fun EventSchemaBuilderScope.SendNetworkRequest(id: String = randomId(), trigger: EventTrigger, events: EventSchemaBuilderScope.() -> Unit = {}, url: String, method: HttpMethod, body: AnySerializable? = null, headers: Map<String, String>? = null, timeouts: TimeoutsSchema? = null)

Sends an HTTP request to url with method, headers, body and an optional timeouts, and emits the response downstream — the general-purpose way to talk to a backend from inside an event chain. A JSON response is parsed into plain maps, lists and primitives (a JSON body that fails to parse yields null); anything else is passed through as a raw ByteArray. Does not consume incomingData. Dispatches onStart before the request is sent; onNetworkResponse(status)/onNetworkFailure(status) (carrying the parsed body) when a child event is wired to that exact HTTP status — the former for 2xx, the latter for the rest; onSuccess (carrying the parsed body) when the response is 2xx and no status-specific event was declared; onFailure (carrying the parsed body, or the Throwable on transport failures like timeout/no connectivity — logged) when the response isn't 2xx and no status-specific event was declared. Exactly one outcome trigger fires per response.

Parameters

id

Unique identifier of this event. Defaults to a random id.

trigger

Trigger that fires this event, built via EventTriggers.

events

Child events chained after this one, wired to its triggers (onStart, onNetworkResponse, onNetworkFailure, onSuccess, onFailure).

url

URL requested.

method

HTTP method used for the request, built with httpGet, httpPost, httpPut, httpDelete, httpPatch etc.

body

Request body. Defaults to none.

headers

Request headers. Defaults to none.

timeouts

Request, connect and socket timeout overrides, built with timeout. Defaults to none (client defaults).