klyn.net.HttpRequest.withBody
method

    public withBody(body as Object) as HttpRequest throws Exception:

Description

Returns a copy with a different request body.

Parameters

Parameter | Description
--- | ---
`body` | Optional request body.

Returns

Updated request.

Throws

- Exception if request validation, serialization, network transport, TLS handling, or response creation fails.

Example

    import klyn.net

    request = HttpRequest("https://example.com/api", "POST").withBody({"hello": "world"})
    print(request.method)