I'm trying to make use of the directions api to draw route on map. I created the interface below so I can call the getRoutes() Function inside the interface in the mainactivity and access texts from edittexts and pass them as the origin and destination, but when I use the interface, it returns an empty route with status = not found. (Mind you, the texts from the edittext is from the places api(place.name), so its a valid address)
RoutesResponse(error_message=null, routes=[], status=NOT_FOUND)
the below is the interface:
interface RouteService{
@Headers("Content-Type: application/json")
@POST("https://maps.googleapis.com/maps/api/directions/json")
fun getRoutes(
@Query("origin") origin: String,
@Query("destination") destination: String,
@Query("mode") mode: String,
@Query("key") apiKey: String
): Call<RoutesResponse>
}
The only time the interface works is when I removed the "@Query" just like it is below.
interface RouteService{
@Headers("Content-Type: application/json")
@POST("https://maps.googleapis.com/maps/api/directions/json?destination=Nadia Bakery, Benin City, Nigeria&origin=Hall 2 (Tinubu Female Hostel), Benin City, Nigeria&key=API_KEY")
fun getRoutes(): Call<RoutesResponse>
}
The above isn't efficient, as I cannot pass texts from the edittext as origin and destination.
How else do I do this so I can be able to use texts entered in the edittext as the origin and destination?