Will look into OkHttp tough, thank you :slightly_s...
# announcements
m
Will look into OkHttp tough, thank you 🙂
👍 1
c
No problem. I'm also wondering if you could write an extension function for Unirest to elevate your gripes. Disclaimer: I've not actually used Unirest and have no idea what the API is like 😛
m
Probably! It would make it bit less ugly to look at at least 😉
😁 1
l
If it's coroutines support you are looking for, there's a pretty simple implementation ready for Retrofit. (https://github.com/gildor/kotlin-coroutines-retrofit)
👌 2
j
@mantono There's also Ktor written by the Jetbrains team http://ktor.io/
m
@jlleitschuh I have already tried ktor. I like the design but I had some trouble parsing the body in POST requests.
j
Huh, care to elaborate? I'm about to start using it much more heavily. If you've had issues I'd like to know about them ahead of time.
m
I can see if I can find the old commit where I used it. It could very well be I who did something wrong.
@jlleitschuh
Copy code
private suspend inline fun <reified T> httpPost(url: String, payload: Any): T {
        return <http://client.post|client.post>(url = url) {
            header("Authorization", "Bearer $apiToken")
            contentType(ContentType.Application.Json)
            accept(ContentType.Application.Json)
            body = jsonString(payload)
        }
    }
j
And it couldn't handle this correctly?
m
I could not get that to work, even when I used HttpResponse as type which should always work according to docs, I always got IncompatibleClassChangeError or something similar.
Or something simple as String did not work either.
j
I got it to work with these:
Copy code
install(JsonFeature)
    install(HttpPlainText) {
        defaultCharset = Charsets.UTF_8
    }
At least, I thought I did.