How to make a correct https request using the Finagle to Telegram API

I am currently working on a simple bot that will have a telegram interface. The problem is that finagle has the means to make an http request, but I don't know how to make an https request. I tried to make an https request with the scala -library finagle for telegram bot API:

val service: Service[http.Request, http.Response] = Http.client.withTlsWithoutValidation.newService("api.telegram.org:443")
val request = http.Request(http.Method.Get,bottoken + "/getMe")
request.host = "api.telegram.org"
val t  = Await.result(service(request) onSuccess(a => a) onFailure( exc => println("Auth check failed : " + exc.toString )))
if (t.status == Status.Ok) {
  println("Auth check success")
} else {
  println("Auth check failed : " + t.toString + "\r\n" + t.contentString)
}

      

Every time I run this code it gives 400 HTTP request requests.

Http.client.withTls("api.telegram.org")

      

gives the same result. What am I doing wrong?

+3


source to share


1 answer


You need to add an HTTP protocol request.



val request = http.Request(http.Method.Get, "http://yourholeHost/getMe")

      

0


source







All Articles