You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const val EXAMPLE_API_TOKEN = "12345123:QkJGb3VsSUdCYk1tdkNFOHJWVm-ak"
fun main() {
val service = Retrofit.Builder()
.baseUrl("https://api.telegram.org/")
.addConverterFactory(MoshiConverterFactory.create())
.build()
.create(TelegramBotService::class.java)
service.getUpdates(EXAMPLE_API_TOKEN).execute()
}
interface TelegramBotService {
@GET("bot{token}/getUpdates")
fun getUpdates(@Path("token") token: String): Call<Any>
}
This will fail with:
Exception in thread "main" java.lang.IllegalArgumentException: Malformed URL. Base: https://api.telegram.org/, Relative: bot12345123:QkJGb3VsSUdCYk1tdkNFOHJWVm-ak/getUpdates
at retrofit2.RequestBuilder.get(RequestBuilder.java:232)
at retrofit2.RequestFactory.create(RequestFactory.java:120)
at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:192)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:175)
at cash.andrew.retrofit.AppKt.main(App.kt:22)
at cash.andrew.retrofit.AppKt.main(App.kt)
By url encoding the api-token and changing the Path annotation to (@Path("token", encoded = true) this will work.
Seems like something that I would expect to be done by retrofit automatically. Let me know if I can provide any more details.
The text was updated successfully, but these errors were encountered:
This will fail with:
By url encoding the api-token and changing the Path annotation to
(@Path("token", encoded = true)
this will work.Seems like something that I would expect to be done by retrofit automatically. Let me know if I can provide any more details.
The text was updated successfully, but these errors were encountered: