setTrackedJsonBody

inline fun <T> HttpRequestBuilder.setTrackedJsonBody(category: NetworkUsageCategory, body: T, json: Json = defaultNetworkJson)(source)

Serializes and records a JSON request body before sending it through Ktor.

Counting the encoded payload here covers providers where Ktor later streams the body and the original object is no longer available to the response parser.

Receiver

Ktor request builder that will receive serialized JSON content.

Author

Dmitriy Moroz

Parameters

category

Traffic bucket that should receive the encoded request byte count.

body

Serializable request payload sent to the provider.

json

Serializer used to encode the payload before it is installed as Ktor content.