hi! how can i tell the http client to allow a stri...
# ktor
b
hi! how can i tell the http client to allow a string as body when content-type = application/json? as soon as i set that header i get the exception "class java.lang.String cannot be cast to class io.ktor.client.call.HttpClientCall"
works with
body = TextContent("""{"name": "$it", "repository":"GE_VIENNA", "rows":10, "metaData": $meta}""", ContentType.Application.Json)
d
Try setting
body
to TextContent
Yup
b
hehe thx
i am using HttpClient(CIO)
at one point i am getting the exception
Exception in thread "main" java.net.BindException: Address already in use: no further information
@Dominaezzz any ideas whats happening there?
d
That's unusual for a client I think.
You're not doing any server stuff?
b
i am doing 30k calls in a short time
Copy code
HttpClient(CIO).use { client ->
            metadata.keys.forEach {
                val meta = jackson.writeValueAsString(metadata.getValue(it))
                client.call {
                    url("$baseUrl/api/matrices/create")
                    method = <http://HttpMethod.Post|HttpMethod.Post>
                    body = TextContent("""{"name": "$it", "repository":"GE_VIENNA", "rows":10, "metaData": $meta}""", ContentType.Application.Json)
                }.close()
            }
        }
it never succeeds
d
Hmm, might be a bug in
CIO
. Have you tried
Apache
?
b
no .. trying it now. is apache the most stable one?
d
It's a stable one with the most config.
Only
CIO
is experimental.
b
works with the apache client
same code
d
Yeah, make a big report when you can.
b
i will