You simply need to pass the variable while you make the request as follows:
First, in your Api interface (Kotlin):
@GET("yourBaseURL" + "{id}")
fun yourFunc(@Path("id") id: Int?): Call<YourServerResponse>
And then, while you make the request, it will ask you for an {id} which you've specified in the Api interface:
val yourVariable = intent.getStringExtra("yourData")
val service = ServiceBuilder.buildService(ApiService::class.java)
service.yourFunc(yourVariable)
.enqueue(object : Callback<YourServerResponse?> {
override fun onResponse(
call: Call<YourServerResponse?>,
response: Response<YourServerResponse?>
) {
if (response.code() == 200 && response.isSuccessful) {
// successful
} else {
// failed
}
}
override fun onFailure(call: Call<YourServerResponse?>, t: Throwable) {
// Error
}
})
Take a look:
Retrofit and GET using parameters
Retrofit 2 - URL Query Parameter