我正在尝试为我的应用程序添加用于 json 请求的改造库。我收到一个非常简单但令人讨厌的错误。
当我执行此方法时:
@GET("/Server/ports/{portCode}")
@Headers({
"Content-Type: application/json",
"Accept-Language: en"
})
void listArrivalPorts(
@Path("portCode") String portCode,
Callback<PGSArrivalPortsResponse> callback
);
我收到此错误:
Retrofit-Idle
java.lang.IllegalStateException: Method path "/Server/ports/{portCode}" does not contain {portCode}.
at retrofit.RestMethodInfo.parseParameters(RestMethodInfo.java:320)
at retrofit.RestMethodInfo.init(RestMethodInfo.java:90)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:202)
at retrofit.RestAdapter$RestHandler.access$300(RestAdapter.java:156)
at retrofit.RestAdapter$RestHandler$1.obtainResponse(RestAdapter.java:189)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:38)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at retrofit.Platform$Android$2$1.run(Platform.java:132)
at java.lang.Thread.run(Thread.java:1019)
但是当我像这样移除替换体时,
@GET("/Server/ports/SOMETHING")
@Headers({
"Content-Type: application/json",
"Accept-Language: en"
})
void listArrivalPorts(
Callback<PGSArrivalPortsResponse> callback
);
它工作正常。
另外,如果我添加参数,@Path("portCode") String portCode
我会得到同样的错误。
为什么会这样?谢谢。