I have two activity and in First Activity I am calling api with retrofit
private fun retrofitConfiguration() {
retrofit = Retrofit.Builder()
.baseUrl("https://abhi-debug.github.io/")
.addConverterFactory(GsonConverterFactory.create())
.build()
}
and Api Interface -
interface ApiService {
@GET("Caption/caption_home.json")
fun fetchUser() : Call<List<Captions>>
@GET(" ")
fun fetchData(): Call<List<Data>>
}
so it give me a json like this-
[
{
"id": 14,
"title": "Demo",
"url": "https://abhi-debug.github.io/Caption/demo.json"
}
]
Here the url-"https://abhi-debug.github.io/Caption/demo.json" will pass in next activity as BaseUrl of Retrofit for Next Activity.
private fun retrofitConfiguration() {
retrofit = Retrofit.Builder()
.baseUrl(**myUrl**)
.addConverterFactory(GsonConverterFactory.create())
.build()
}
myUrl is getting from (FirstActivity)json like this-
myUrl = intent.getStringExtra("URL")
in FirstActivity
urlForNextActivity[pos] = captionsList[pos].url
val intent = Intent(context, **SecondActivity**::class.java)
intent.putExtra("URL", urlForNextActivity[position])
context.startActivity(intent)
Error at runtime
Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: https://abhi-debug.github.io/Caption/demo.json
Note- https://abhi-debug.github.io/Caption/demo.json is fixed it cant have / at end
So is there any way to call it