[英]Android Retrofit2 error @Url
I am having an issue with my Retrofit code, and I seem to be either missing something or not fully understanding what I need done. 我的Retrofit代码有问题,似乎丢失了某些东西或者没有完全理解我需要做的事情。 Here is a full copy of my error.This is my code, why @Url can't use: 这是我的错误的完整副本。这是我的代码,为什么@Url无法使用:
private interface ApiManagerService {
//step 1: get car's info link from server
@GET("v2/link/carillegal")
Observable<CarInfoUrl> getCarInfoUrl(@QueryMap Map<String, String> params);
//step 2: get car's info from step 1 link
@GET
Observable<String> queryCarInfo(@Url String url);
//step 3: call back our server with car info from step 2
@POST("v2/package/carillegal")
Observable<String> callBackCarInfo(@QueryMap Map<String, String> params, @Body String value);
...
}
Observable.just("1")
.flatMap(new Func1<String, Observable<CarInfoUrl>>() {
@Override
public Observable<CarInfoUrl> call(String value) {
System.out.println("Observable call1:" + value);
return ApiManager.getCarInfoUrl(carInfoArray[0], "2203");
}
})
.flatMap(new Func1<CarInfoUrl, Observable<String>>() {
@Override
public Observable<String> call(CarInfoUrl carInfoUrl) {
System.out.println("Observable call2:" + carInfoUrl.getLink());
return ApiManager.queryCarInfo(carInfoUrl.getLink());
}
})
....
});
and throw Exception: 并抛出异常:
Exception in thread "main" java.lang.IllegalArgumentException: HTTP method annotation is required (e.g., @GET, @POST, etc.).
for method ApiManagerService.queryCarInfo
at retrofit.Utils.methodError(Utils.java:177)
at retrofit.Utils.methodError(Utils.java:167)
at retrofit.RequestFactoryParser.parseMethodAnnotations(RequestFactoryParser.java:135)
at retrofit.RequestFactoryParser.parse(RequestFactoryParser.java:59)
at retrofit.MethodHandler.create(MethodHandler.java:30)
at retrofit.Retrofit.loadMethodHandler(Retrofit.java:151)
at retrofit.Retrofit$1.invoke(Retrofit.java:132)
at com.xlzg.wzcx.lib.api.$Proxy0.queryCarInfo(Unknown Source)
at com.xlzg.wzcx.lib.api.ApiManager.queryCarInfo(ApiManager.java:131)
at com.xlzg.wzcx.lib.MyClass.main(MyClass.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
对于Retrofit 2,您可以设置@GET(".")
声明最终URL与基本URL相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.