import java.lang.StringBuilder
import java.net.HttpURLConnection

// https://lms.fu-berlin.de/learn/api/v1/courses?fields=id,name,description,courseId,startDate,endDate
// paging.nextPage

suspend fun sendGet(uri: String): String {
    val url = URL(uri)
    url
    val str = StringBuilder()
    with(url.openConnection() as HttpURLConnection) {
        requestMethod = "GET"  // optional default is GET
        addRequestProperty("Cookie", "JSESSIONID=1C7D8F7562968A6693BDD5C5F049D35A; session_id=8286C021DFB6CCA0DB4089A1D31EB422; s_session_id=C2CB57E4AEEFBF6496A09F517CDBDE91; web_client_cache_guid=f6ec07e0-7c39-4d0e-b690-5abab8d6cc06; loginType=shibboleth; JSESSIONID=3929500B4C87181844342524E78BDC89; _shibsession_64656661756c7468747470733a2f2f6c6d732e66752d6265726c696e2e64652f73686962626f6c657468=_a144d509c3e7defaec6a5a7d23d5f00c")
        println("\nSent 'GET' request to URL : $url; Response Code : $responseCode")
        inputStream.bufferedReader().use {
            it.lines().forEach { line ->
                str.append(line);
            }
        }
    }
    return str.toString()
}

launch {
    val x = sendGet("https://lms.fu-berlin.de/learn/api/v1/courses?fields=id,name,description,courseId,startDate,endDate")
    println(x)
}