android - 改造:如何修复 "only one http method is allowed. found: get and get"?

标签 android retrofit

我有请求的结构。
请求 getTransportByStation 工作完美。 但是我得到异常 java.lang.IllegalArgumentException: TransportWebService.getTransportByRoute: Only an HTTP method is allowed.找到:GET 和 GET。 我只找到了 POST 和 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:改造版本 1.9.0
像这样初始化服务

private static final TransportWebService SERVICE = Common.getRestAdapter()
            .setConverter(new GsonConverter(new Gson())
            .build()
            .create(TransportWebService.class);

最佳答案

在第二个 GET 方法中,第二个参数 (@PATH("station")) 应该是 @PATH("route")。

关于android - 改造:如何修复 "only one http method is allowed. found: get and get"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29556313/

相关文章:

Android Retrofit AES 加密/解密 POST 和响应

java - 改造中设置宽松错误 :1. 8.0

java - 使用 openweathermap api 的日期和时间

android - 如何获取手机中安装的android固件版本?

android - 带有改造 Android 的可选文件

android - 如何在 fragment 中使用 Retrofit 和 Loader 类

android - 使用 rxandroid 调用改造 api 时刷新身份验证 token

android - 如何调整图库中图像的大小

android - 有没有办法用我的 Json 数据设置可绘制文件夹中的图像,该数据包括可绘制文件夹中图像的名称

Android - 横向覆盖的导航栏