rybalkinsd / kohttp

Kotlin DSL http client
https://kohttp.gitbook.io
Apache License 2.0
478 stars 42 forks source link

Function to in FormBodyBuilder with nullable type has unexpected behavior #206

Closed MEJIOMAH17 closed 3 years ago

MEJIOMAH17 commented 3 years ago
 val paramArg= json.decodeFromString<Map<String, String>>(rs)["params"]

 val result = httpPost{
     url("https://example.com")
     body {
        form {
            "params" to paramArg
        }
     }
 }

This code does not append 'params' arg to form, because function to works with nonnullable type. paramArg is nullable, therefore function 'to' works from standart kotlin library.

rybalkinsd commented 3 years ago

Hi @MEJIOMAH17 thanks for reporting this one! Could you please share how http request form should look like with null? (params=???)

MEJIOMAH17 commented 3 years ago

@rybalkinsd I have created PR.