改造:如何修复“只允许一种 http 方法".发现:获取和获取"? [英] Retrofit: how fix "only one http method is allowed. found: get and get"?

查看:54
本文介绍了改造:如何修复“只允许一种 http 方法".发现:获取和获取"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有请求的结构.
请求 getTransportByStation 完美工作.但我得到异常 java.lang.IllegalArgumentException: TransportWebService.getTransportByRoute: Only one HTTP method is allowed.找到:GET 和 GET.我找到了仅适用于 POST 和 POST 的解决方案.

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:改造版本 1.9.0
像这样初始化服务

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);

推荐答案

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

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

这篇关于改造:如何修复“只允许一种 http 方法".发现:获取和获取"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆