request

abstract fun <T : Any> request(kClass: KClass<T>): AnyEndpoint.Builder(source)

Declares the request body type.

When a client makes a request to the server, the client will need to pass an instance of this type.

Under the hood, this method uses Ktor's content negotiation features. Therefore, all types that would be valid with content negotiation can be used with this library. Note that you may need to perform some configuration on the Ktor side before using some types, see the official documentation for instructions.

Example

val list by post()
.request<UserCreationDto>()
.response<UserDto>()

If this method is called multiple times, only the last call is retained.

See also