How to consume data from url

I have url address which accept data from 3rd party server. How can I consume the data from that url? I know that this url accept only post request. So how I can I receive that data in my kotlin app?

>Solution :

This is usually done by using an HTTP client library, so you can more easily convert payloads etc.

There are many HTTP clients to pick from. Among them are Ktor client (Kotlin-first, coroutine-based), Retrofit (very classic on Android), or even the built-in JDK11 HttpClient (although this one is not very Kotlin-friendly), but also many others.

If your code is multiplatform, Ktor would be a particularly good choice.

Leave a Reply