1

I want to call another web-api from my backend on a specific request of user.

How can I achieve this in Ktor. Like in spring boot we use Rest Template, but how can I do the same in Ktor.

Reference Article for doing the same in spring boot: (Call another rest api from my server in Spring-Boot)

lunarzshine
  • 321
  • 2
  • 9

2 Answers2

2

You can use ktor http client

val client = HttpClient(CIO)
val response: HttpResponse = client.get("https://ktor.io/")
println(response.status)
client.close()

Making HTTP requests in ktor

Example

Naveen Kumar
  • 3,738
  • 4
  • 29
  • 50
0

Use an HTTP client like Unirest to make the call to the other web api

Unirest.get("https://reqres.in/api/users/1").asString();

https://kong.github.io/unirest-java/

Asad Awadia
  • 1,417
  • 2
  • 9
  • 15