HTTP characterizes an arrangement of request functions to demonstrate the coveted activity to be performed for a given resource. The GET function requests a description of the predetermined resource and requests that utilizing GET should just retrieve data. GET is a standout among the most well-known HTTP functions.
Here are the common functions of HTTP GET:
@Throws(RestClientException::class)
fun <T> getForObject(url: String, responseType: Class<T>, vararg urlVariables: Any): T
@Throws(RestClientException::class)
fun <T> getForObject(url: String, responseType: Class<T>, urlVariables: Map<String, *>): T
@Throws(RestClientException::class)
fun <T> getForObject(url: URI, responseType: Class<T>): T
fun <T> getForEntity(url: String, responseType: Class<T>, vararg urlVariables: Any): ResponseEntity<T>
fun <T> getForEntity(url: String, responseType: Class<T>, urlVariables: Map<String, *>): ResponseEntity<T>
@Throws(RestClientException::class)
fun <T> getForEntity(url: URI, responseType: Class<T>): ResponseEntity<T>
Here is an example of how to call these functions:
val restTemplate = RestTemplate()
val baseUrl: String ?= "YOUR_URL" // API URL as String
val response = restTemplate.getForEntity(baseUrl, String::class.java)
val uri = URI(baseUrl) // API URL as URL format
val responseURI = restTemplate.getForEntity(uri, String::class.java)Auth Module