0

how can i send a requestBody using this :

try {
        data =(URL("<URL>" + path).openConnection() as HttpsURLConnection).apply {
            sslSocketFactory = createSocketFactory(listOf("TLSv1.2"))
            hostnameVerifier = HostnameVerifier { _, _ -> true }
            readTimeout = 5_000
            
        }.inputStream.bufferedReader().readText()
    } catch (e: Exception) {
        println("error").toString()
    }

The code is written with Kotlin

1 Answers1

1

Similar question here. I highly recommend a simple library like http4k

val client = JavaHttpClient()
val request = Request(Method.GET, "https://google.com")
val response = client(request)
s1m0nw1
  • 76,759
  • 17
  • 167
  • 196