Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit: how fix "only one http method is allowed. found: get and get"?

I have that structure for request.
Request getTransportByStation work perfectly. But I get exception java.lang.IllegalArgumentException: TransportWebService.getTransportByRoute: Only one HTTP method is allowed. Found: GET and GET. I found solution only for POST and POST.

interface TransportWebService {
    @GET(QUERY_CATEGORY_TRANSPORT + "GetTransportByNextStation/{station}")
    Observable<ResponseRouteList> getTransportByStation(
            @Path("city") String city,
            @Path("station") String station,
            @Query("count") int count,
            @Query("userid") String userId
    );

    @GET(QUERY_CATEGORY_TRANSPORT + "GetTransportByRoute/{route}")
    Observable<ResponseRouteList> getTransportByRoute(
            @Path("city") String city,
            @Path("station") String route,
            @Query("count") int count,
            @Query("userid") String userId
    );

    @GET(QUERY_CATEGORY_TRANSPORT + "Time")
    Observable<Integer> getTime(
            @Path("city") String city
    );
}

UPD: Retrofit version 1.9.0
Init service like this

private static final TransportWebService SERVICE = Common.getRestAdapter()
            .setConverter(new GsonConverter(new Gson())
            .build()
            .create(TransportWebService.class);
like image 827
andreich Avatar asked Apr 10 '15 08:04

andreich


1 Answers

In the second GET method, the second argument (@PATH("station")) should be @PATH("route").

like image 118
Siri0S Avatar answered Oct 12 '22 02:10

Siri0S