post

abstract fun post(body: JsonObject = buildJsonObject {})

Sets the request body as JSON with POST method.

This method automatically sets the HTTP method to POST and the Content-Type to application/json. The JSON object is serialized to a string.

Parameters

body

The JSON object to send. Defaults to an empty object.


abstract fun post(contentType: String = CONTENT_TYPE, body: String)

Sets the request body with POST method and custom content type.

This method sets the HTTP method to POST and allows specifying a custom Content-Type header along with the body content as a string.

Parameters

contentType

The Content-Type header value (e.g., "text/plain", "application/xml").

body

The request body as a string.