Field

annotation class Field(val value: String = KTORGEN_DEFAULT_NAME, val encoded: Boolean = false)

A named pair for a form-encoded request.

Needs to be used in combination with @FormUrlEncoded

@POST
@FormUrlEncoded
suspend fun example(@Field name: String, @Field("job") occupation: String): Employee

foo.example("Bob Smith", "President")
// Generate name=Bob+Smith&job=President

Arrays/vararg example:

@POST
@FormUrlEncoded
suspend fun example(@Field vararg name: String): List<Employee>

example("Bob Smith", "Jane Doe")
// Generate name=Bob+Smith&name=Jane+Doe

See also

Properties

Link copied to clipboard
val encoded: Boolean = false

Specifies whether the names and values are already URL encoded.

Link copied to clipboard

Name of the parameter. Default the name of the function parameter