GET

Get requests can be made in two different ways. First one is string extension, second is via kotlin dsl.

String.httpGet() extension

val response: Response = "https://google.com/search?q=iphone".httpGet()

GET with request parameters

val response: Response = httpGet {
   host = "google.com"
   path = "/search"
   param {
       "q" to "iphone"
       "safe" to "off"
   }
}

or

val response: Response = httpGet {
   url("https://google.com/search")
   param {
       "q" to "iphone"
       "safe" to "off"
   }
}

GET with header and cookies

Last updated

Was this helpful?